Change char case
In this chapter you will learn:
Is Character a upper/lower Case
The following code uses Character.isUpperCase
method to tell is a char a uppercase char
public class Main {
public static void main(String[] args) {
char symbol = 'A';
/*from j a va 2s . c o m*/
if (Character.isUpperCase(symbol)) {
System.out.println("true");
}else{
System.out.println("false");
}
}
}
The code above generates the following result.
We can also check the lower case letter.
public class MainClass {
public static void main(String[] args) {
char symbol = 'A';
/* j a va 2s . c om*/
if (Character.isLowerCase(symbol)) {
System.out.println("true");
}else{
System.out.println("false");
}
}
}
The code above generates the following result.
Change character case
static char toTitleCase(char ch)
converts to titlecase.static char toUpperCase(char ch)
converts to uppercase.static char toLowerCase(char ch)
converts to lowercase.
public class Main{
public static void main(String[] argv){
System.out.println(Character.toTitleCase('a'));
System.out.println(Character.toUpperCase('a'));
System.out.println(Character.toLowerCase('a'));
//from ja va 2s . c o m
}
}
The output:
Next chapter...
What you will learn in the next chapter:
- How to get char value from Character object
- How to get the numeric value for a char
- How to convert character to String
- How to convert int value to char value
Home » Java Tutorial » Primitive Data Types