Home » Online Computer Education » Learn Fundamentals of Java Programming “String Manipulation in Java Programming ” Lesson 25
Learn Fundamentals of Java Programming “String Manipulation in Java Programming ” Lesson 25
String Manipulation
In the previous section, we learned to manipulate arrays using Java prebuilt classes. In this section we learn to manipulate Strings using the String class present in the java.lang package. The first method we will use from the String class is the toUpperCase() method. This method converts a string to all uppercase letters.
String myString = “Hello World”;
System.out.println(“UpperCase: ” + myString.toUpperCase());
The output of the code given above will be:
HELLO WORLD
The following table shows the commonly used String class methods and the result of applying them on the string “Hello World”.
Figures 1.9g and 1.9h show the String Demo program and its output respectively.