substring(5 1) code example
Example 1: 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;
}
}
Example 2: str.substring if 2 letters
public String firstTwo(String str) {
return str.length() < 2 ? str : str.substring(0, 2);
}