Answers for "string manipulation instructions?]"

0

String manipulations

boolean eq = name.equals(anotherName);                // equality

String fruit = "Apple";
int position = fruit.indexOf("pp");                   // 1 (if not found, -1)

int length = fruit.length()                           // 5 (lenght)

String sub = fruit.substring(1, 4);                   // exp: (1. index get into, 4. index does not)

String upper = fruit.toUpperCase();                   // APPLE

boolean empty = fruit.isEmpty();                      // false, with empty string true
boolean blank = fruit.isBlank();                      // false, only true with white space character

boolean startsWith = fruit.startsWith("app");         // true
boolean endWith = fruit.endsWith("le");               // true
boolean containsDoubleP = fruit.contains("pp");       // true
String part = fruit.substring(0, 2).toLowerCase();    // ap - can be join
Posted by: Guest on April-25-2021

Code answers related to "string manipulation instructions?]"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language