This program accepts the string from the keyboard and convert all the characters in the strings into upper cases and vice versa.
import java.io.*;
/**
*
* @author JavaHotSpot
*/
public class stringULCase
{
public static void main(String args[])
{
String s1,s2,upper,lower;
DataInputStream d;
try
{
System.out.println("Enter the String in Lowercase");
d=new DataInputStream(System.in);
s1=(String)d.readLine();
upper=s1.toUpperCase();
System.out.println("Lowercase="+s1+" Uppercase ="+upper);
System.out.println("Enter the String in Uppercase");
s2=(String)d.readLine();
lower=s2.toLowerCase();
System.out.println("Uppercase="+s2+" Lowercase ="+lower);
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
Output:
Enter the String in Lowercase
javaatweet
Lowercase=javahotspot Uppercase =JAVAHOTSPOT
Enter the String in Uppercase
JAVAHOTSPOT
Uppercase=JAVAHOTSPOT Lowercase =javahotspot
Related Articles:
Java Programming Example of how to extract substring from the given string
Java Programming Example of how to remove the extra spaces from the given string
Java Programming Example of how to convert string into bytes
Java Programming Example of how to convert String into characters and display the character?
Java Programming Example of how to replace old character with new character in the string
Java Programming Example to check whether the strings starts with given prefix and ends with given suffix or not?
Java Programming Example of finding the length of the given string
Java Programming Example of concatenation of two strings
Java Programming Example to check whether the two strings are equal or not?
Related Articles:
Java Programming Example of how to extract substring from the given string
Java Programming Example of how to remove the extra spaces from the given string
Java Programming Example of how to convert string into bytes
Java Programming Example of how to convert String into characters and display the character?
Java Programming Example of how to replace old character with new character in the string
Java Programming Example to check whether the strings starts with given prefix and ends with given suffix or not?
Java Programming Example of finding the length of the given string
Java Programming Example of concatenation of two strings
Java Programming Example to check whether the two strings are equal or not?