Character function in Java

Hello friends how are you, today in this blog i will teach you what is Character function, types of Character function, how Character functions work and many programs using Character functions in a very simple way. 

Let's start 

Here we are going to learn all Character functions one by one
      1 toUpperCase()
  • Converts the given char into uppercase form.
class Easy
{  
 public static void main(String[] args) 
 {
   System.out.println(Character.toUpperCase('a'));
   System.out.println(Character.toUpperCase('A'));
 }
}
/*
### OUTPUT ###
A
A
*/
  • 2 toLowerCase()
  • Converts the given char into lowercase form.
class Easy
{  
 public static void main(String[] args) 
 {
   System.out.println(Character.toLowerCase('a'));
   System.out.println(Character.toLowerCase('A'));
 }
}
/*
### OUTPUT ###
a
a
*/
  • 3 isLetter()
  • Used to check the given char is letter or not.
  • It returns boolean value(True/False).
  • Returns true if char is letter otherwise returns false.
class Easy
{  
 public static void main(String[] args) 
 {
   System.out.println(Character.isLetter('a')); 
   System.out.println(Character.isLetter('9'));
 }
}
/*
### OUTPUT ###
true
false
*/
  • 4 isDigit()
  • Used to check the given char is digit or not.
  • It returns boolean value(True/False).
  • Returns true if char is digit otherwise returns false.
class Easy
{  
 public static void main(String[] args) 
 {
   System.out.println(Character.isDigit('a')); 
   System.out.println(Character.isDigit('9'));
 }
}
/*
### OUTPUT ###
false
true
*/
  • 5 isUpperCase()
  • Used to check the given char is uppercase or not.
  • It returns boolean value(True/False).
  • Returns true if char is uppercase otherwise returns false.
class Easy
{  
 public static void main(String[] args) 
 {
   System.out.println(Character.isUpperCase('a')); 
   System.out.println(Character.isUpperCase('A'));
 }
}
/*
### OUTPUT ###
false
true
*/
  • 6 isLowerCase()
  • Used to check the given char is lowercase or not.
  • It returns boolean value(True/False).
  • Returns true if char is lowercase otherwise returns false.
class Easy
{  
 public static void main(String[] args) 
 {
   System.out.println(Character.isLowerCase('a')); 
   System.out.println(Character.isLowerCase('A'));
 }
}
/*
### OUTPUT ###
true
false
*/
  • 7 isWhiteSpace()
  • Used to check the given char is white space or not.
  • It returns boolean value(True/False).
  • Returns true if char is white space otherwise returns false.
class Easy
{  
 public static void main(String[] args) 
 {
   System.out.println(Character.isWhitespace(' ')); 
   System.out.println(Character.isWhitespace('A'));
 }
}
/*
### OUTPUT ###
true
false
*/


Request:-If you found this post helpful then let me know by your comment and share it with your friend. 

If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. 

Try to learn something new and teach something new to other. Thanks.

Post a Comment

0 Comments