Sunday, 27 July 2014

How to make a Sub String from a String in Java

Structure of the Problem Requirements


In this Problem we will create a sub string from a string. The user will give a index number of a string and the program make new string from that number. The Program will receive the string from the user and then create new string according to the index  enter number.

Source Code   


package com.ancodingpoint.ww.w;

import java.util.Scanner;

public class String_Function {

    public static void main(String[] args) {
        Scanner input = new Scanner (System.in);
        String a = "";
        int b = 0;
        System.out.println(" Enter Your Story Here !..... ");
        a = input.nextLine();
        System.out.println(" Enter the Index Number from where you want to cut and put themin new String ");
       b = input.nextInt();
       System.out.println(" You Press " + b + "and your sub string is below ");
       System.out.println(a.substring(b));
       //System.out.println(a);
    }
    
}


Output of the Program

Java String Programming
Sub String in Java







Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment