String Text Processing
String Text Processing
String Text Processing
indexOf/lastIndexOf /SB
String fruits = "banana apple kiwi banana";
System.out.println(fruits.indexOf("banana")); // 0
System.out.println(fruits.indexOf("orange")); // -1
System.out.println(fruits.lastIndexOf("banana")); // 18
System.out.println(fruits.lastIndexOf("orange")); // -1
indexOf – pokazva na koi index se sreshta za pruv put ako nqma
takava duma printva -1
lastIndexOf – pokazva na koi index za posledno se poqvqva
dumata ako nqma takava printva -1
replace – zamestva dadenata duma(ako e ima) s tova koeto
iskame
String word = scanner.nextLine(); // pie
numbers.delete(0, 5);
System.out.println(numbers); // 6789
if (Character.isDigit(token)) {
numbers.append(token);
} else if (Character.isLetter(token)) {
letters.append(token);
} else {
symbols.append(token);
}
}
System.out.println(numbers); // 22
System.out.println(letters); // aA
System.out.println(symbols); // %%