Extracting substrings from a string - Java Language Basics

Java examples for Language Basics:String

Description

Extracting substrings from a string

Demo Code

public class Main {
  public static void main(String[] args) {
    String s = "Baseball";
    String b = s.substring(4);//www . ja  va  2s . com
    System.out.println(b);
    s = "Baseball";
    b = s.substring(2, 6);
    System.out.println(b);
  }

}

Related Tutorials