How to make a Sub String from a String in Java

In this Problem we will create a sub string from a string. The user will give an index number of a string and the program make new string from that 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

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment