String
String
String
• char p=‘m’;
• String q=“computer applications”;
Character functions
• Character.isLetter()-to check whether a given argument is an alphabet or not.
Eg: boolean p = Character.isLetter(‘c’); true
• Character.isUpperCase()- This function will return true if the given argument is an upper case letter or not.
Eg: boolean p = Character.isUpperCase(‘A ’); true
boolean p = Character.isUpperCase(‘ g’); false
• Character.isLowerCase()- This function will return true if the given argument is an lowercase letter or not.
Eg: boolean p = Character.isLowerCase(‘A ’); false
boolean p = Character.isLowerCase(‘ g’); true
• Character.toUpperCase()- This function will return the given argument in upper case .
Eg: boolean p = Character.toUpperCase(‘a ’); A
boolean p = Character.isUpperCase(‘ G’); G
boolean p = Character.isUpperCase(‘ ?’); ?
• Character.toLowerCase()- This function will return the given argument in lower case .
Eg: boolean p = Character.toLowerCase(‘a ’); a
boolean p = Character.isLowerCase(‘ G’); g
boolean p = Character.isLowerCase(‘ ?’); ?
Conversion from characters to ASCII code and vice versa
Characters ASCII Codes
0-9 48 – 57
A-Z 65 – 90
a-z 97 - 122
• toUpperCase() – returns a string after converting all the charcters in uppercase letters.
Eg: String s= “computer”;
String p=s.toUpperCase(); “COMPUTER”
• equals() – to comparetwo strings together to check whether they are identical or not.
Eg: 1) String X= “COMPUTER”;
String y= “APPLICATIONS”;
boolean z= x.equals(y); false
2) Eg: String X= “COMPUTER”;
String y= “computer”;
if( x.equals(y)) System.out.println(“same”) ;
else System.out.println(“different”); different
• equalsIgnoreCase() – used to compare two strings
to ensure whether both are identical or not ignoring
the case.