Write a program using String manipulation functions code example

Example: 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

Tags:

Misc Example