Character FunctionsConversions to AsciiString functionsPrimitive data types
These functions deal only with character manipulation                               Character.isUpperCase() Character.isLe...
Enter a letter :                    A      The entered character is a letter    This function checks whetherthe entered ch...
Enter a letter :                      3       The entered character is a digit     This function checks whetherthe entered...
Character.isLetterOrDigit(     )        Enter a letter :                       A                 Enter a digit : 3        ...
Character.isWhiteSpace()     Enter a letter : )                    (      There is a white space   This function checks wh...
Character.isUpperCase()       Enter a letter :                      A        The entered character is in uppercase       T...
Enter a letter :                          d           The entered character is a letter          This function checks whet...
Enter a letter :                        A         The character after conversion is   aThis function converts the capital ...
Character.toUpperCase()      Enter a letter :                     h       The character after conversion is   HThis functi...
class first{void main(char p){if(Character.isLetter(p)         System.out.println(p+ “ is a letter”);else         System.o...
class first{void main(char p){if(Character.isDigit(p)         System.out.println(p+ “ is a Digit”);else         System.out...
class first{void main(char p){if(Character.isLetterOrDigit(p)         System.out.println(p+ “ is a letter or digit”);else ...
class first{void main(char p){if(Character.isUpperCase(p)         System.out.println(p+ “ is an UpperCase”);else         S...
class first{void main(char p){if(Character.isLowerCase(p)         System.out.println(p+ “ is a LowerCase”);else         Sy...
class first{void main(char p){char x =Character.toUpperCase(p);System.out.println(“ The character after conversion is ” + ...
class first{void main(char p){char x =Character.toLowerCase(p);System.out.println(“ The character after conversion is ” + ...
CHARACTERS   ASCII CODES0-9          48-57A-Z          65-90a-z          97-122
char p = „A‟;                    int n = (int)p;This will give the output as 65 because the ASCII value of A is 65
int x = 91;char c = (char) x;     This will give the output as b     B= 66     66+32 = 98     Hence 98 is b
The difference between ASCII code of an upper case andthe corresponding lower case is 32
Get the ASCII code of upper case characterIncrease ASCII code by 32Obtain character corresponding to the increased ASCII c...
Get ASCII code of lower case characterDecrease ASCII code by 32Obtain character corresponding to the decreased ASCII code
These functions deal with strings                                    equalsIgnoreCase()                                   ...
This is used to find the length of the given stringSyntax:int var = string var.length();ExString s = “COMPUTER”;Int l = s....
This is used to find the character at a particular positionof the given stringSyntax:char var = string var.charAt(index);E...
Strings in java
Strings in java
Strings in java
Strings in java
Strings in java
Upcoming SlideShare
Loading in...5
×

Strings in java

566

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
566
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Strings in java"

  1. 1. Character FunctionsConversions to AsciiString functionsPrimitive data types
  2. 2. These functions deal only with character manipulation Character.isUpperCase() Character.isLetterOrDigit() Character.isWhiteSpac Character.toUpperCase() e()
  3. 3. Enter a letter : A The entered character is a letter This function checks whetherthe entered character is a letter or notIt return boolean value True or False
  4. 4. Enter a letter : 3 The entered character is a digit This function checks whetherthe entered character is a number or not It return boolean value True or False
  5. 5. Character.isLetterOrDigit( ) Enter a letter : A Enter a digit : 3 The entered character is a letter entered character is a digit The This function checks whetherthe entered character is a letter or a digit. It may be both It return boolean value True or False
  6. 6. Character.isWhiteSpace() Enter a letter : ) ( There is a white space This function checks whether There is a blank spaceIt return boolean value True or False
  7. 7. Character.isUpperCase() Enter a letter : A The entered character is in uppercase This function checks whetherthe entered character is capital letter or not It return boolean value True or False
  8. 8. Enter a letter : d The entered character is a letter This function checks whetherthe entered character is a lower case letter or not It return boolean value True or False
  9. 9. Enter a letter : A The character after conversion is aThis function converts the capital letter to small letter
  10. 10. Character.toUpperCase() Enter a letter : h The character after conversion is HThis function converts the lower case letters to upper case
  11. 11. class first{void main(char p){if(Character.isLetter(p) System.out.println(p+ “ is a letter”);else System.out.println(p+ “ is not a letter”);}}
  12. 12. class first{void main(char p){if(Character.isDigit(p) System.out.println(p+ “ is a Digit”);else System.out.println(p+ “ is not a Digit”);}}
  13. 13. class first{void main(char p){if(Character.isLetterOrDigit(p) System.out.println(p+ “ is a letter or digit”);else System.out.println(p+ “ is not a letter or digit”);}}
  14. 14. class first{void main(char p){if(Character.isUpperCase(p) System.out.println(p+ “ is an UpperCase”);else System.out.println(p+ “ is not an Upper Case”);}}
  15. 15. class first{void main(char p){if(Character.isLowerCase(p) System.out.println(p+ “ is a LowerCase”);else System.out.println(p+ “ is not a lower Case”);}}
  16. 16. class first{void main(char p){char x =Character.toUpperCase(p);System.out.println(“ The character after conversion is ” + x);}}
  17. 17. class first{void main(char p){char x =Character.toLowerCase(p);System.out.println(“ The character after conversion is ” + x);}}
  18. 18. CHARACTERS ASCII CODES0-9 48-57A-Z 65-90a-z 97-122
  19. 19. char p = „A‟; int n = (int)p;This will give the output as 65 because the ASCII value of A is 65
  20. 20. int x = 91;char c = (char) x; This will give the output as b B= 66 66+32 = 98 Hence 98 is b
  21. 21. The difference between ASCII code of an upper case andthe corresponding lower case is 32
  22. 22. Get the ASCII code of upper case characterIncrease ASCII code by 32Obtain character corresponding to the increased ASCII code
  23. 23. Get ASCII code of lower case characterDecrease ASCII code by 32Obtain character corresponding to the decreased ASCII code
  24. 24. These functions deal with strings equalsIgnoreCase() compareTo() indexOf() Replace() endswith() lastIndexOf() Concat() startswith() Sudstring() equals() trim()
  25. 25. This is used to find the length of the given stringSyntax:int var = string var.length();ExString s = “COMPUTER”;Int l = s.length();System.out.println(l);The output will be 8
  26. 26. This is used to find the character at a particular positionof the given stringSyntax:char var = string var.charAt(index);ExString s = “COMPUTER”;char c = s.charAt(3);System.out.println(c);The output will be P

×