Answers for "What are some of the methods offered by the String class"

3

What are some of the methods offered by the String class

String first = "Wissam"; String last = new String("Fawaz");
System.out.println(first.charAt(0)); // W
System.out.println(last.charAt(last.length() - 1)); // z
String full = first.concat(" ").concat(last); 
System.out.println(full); // Wissam Fawaz		
System.out.println(first.toUpperCase()); // WISSAM
System.out.println(last.toLowerCase()); // fawaz		
System.out.println(first.equals(last)); // false
System.out.println(full.substring(full.indexOf(' ') + 1)); // Fawaz		
System.out.println(full.indexOf('a')); // 4		
System.out.println(full.lastIndexOf('a')); // 10
System.out.println(first.replace('s', 'x')); // Wixxam
Posted by: Guest on April-02-2022

Code answers related to "What are some of the methods offered by the String class"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language