Answers for "java get substring"

69

java substring

String s = "Let's Get This Bread";

String subString = s.substring(6, 9);
				// (start index inclusive, end index exclusive)

// subString == "Get"
Posted by: Guest on February-18-2020
10

how to do substring java

class Main {
  public static void main (String[] args) {
    
    String str = "Hello World!";
    
    String firstWord = str.substring(0, 5);
    //two parameters are start and end index: (inclusive, non-inclusive)
    
    String secondWord = str.substring(6, 11);
    
    //firstWord has string "Hello"
    //secondWord has string "World"
  }
}
Posted by: Guest on May-27-2020
9

how to substring in java

class scratch{
    public static void main(String[] args) {
        String hey = "Hello World";
        System.out.println( hey.substring(0, 5) );
        // prints Hello;
    }
}
Posted by: Guest on January-08-2020
1

substring java

import java.lang.*;

public class StringDemo {
public static void main(String[] args) {
String str = "This is tutorials point";
String substr = "";

// prints the substring after index 8 till index 17
substr = str.substring(8, 17);
System.out.println("substring = " + substr);

// prints the substring after index 0 till index 8
substr = str.substring(0, 8);
System.out.println("substring = " + substr);
}
}
Posted by: Guest on November-26-2020
1

java get substring

// substring(int begin, int end)
String n = "hello there general kenobi";
System.out.println(n.substring(6, 11));
// -> "there"
Posted by: Guest on March-14-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language