String Methods in Java


Strings come with many useful methods. Practice these to manipulate text efficiently.

Source Code

String txt = "Hello World";
System.out.println("Text Length: " + txt.length());
System.out.println(txt.toUpperCase()); // HELLO WORLD
System.out.println(txt.toLowerCase()); // hello world
System.out.println(txt.indexOf("World")); // 6
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments