Answers for "Some of the methods of String class in Java"

3

Some of the methods of String class in Java

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 "Some of the methods of String class in Java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language