String Methods: =============== Getting of the Unicode Value of the Character in the given string: ================================================================== Alphabets A-Z ==> 65 to 90 a-z ==> 97 to 122 0-9 ==> 48 to 57 special characters etc. codePointAt(): ============= Syntax: string-object.codePointAt(index) class GettingUnicodeValues{ public static void main(String[] args) { String s1 = new String("Hello"); System.out.println("The Unicode values of each character = "); System.out.println(s1.codePointAt(0)); System.out.println(s1.codePointAt(1)); System.out.println(s1.codePointAt(2)); System.out.println(s1.codePointAt(3)); System.out.println(s1.codePointAt(4)); // System.out.println(s1.codePointAt(5)); } } Q: WAP TO PRINT ALL THE UNICODE VALUES OF THE STRING CHARACTERS USING LOOP. /* The Unicode of character = 65 */ import java.util.Scanner; class GettingUnicodeValues{ public static void main(String[] args) { Scanner sco = new Scanner(System.in); System.out.println("Enter the string:"); String s = sco.nextLine(); System.out.println("The Unicode Values = "); for(int i = 0;i < s.length();++i) { System.out.println(s.charAt(i)+" = "+s.codePointAt(i)); } } } ================================== next() Vs nextLine(): ==================== next() ==> can read the string characters up to the space nextLine() ==> can read all the characters of the string including the space also. ============================================ codePointCount(): =============== Syntax: getting of the number of Unicode values from the range: String-object.codePointCount(start-index, end-index); class GettingUnicodeValues{ public static void main(String[] args) { String s2 = "Hello Java"; System.out.println(s2.codePointCount(4,7)); System.out.println(s2.codePointCount(1,9)); // System.out.println(s2.codePointCount(0,20)); // System.out.println(s2.codePointAt(20)); } } ======================================= // WAP TO ACCEPT THE STRING AND PRINT THE UNICODE VALUES OF THE CHARACTERS FROM INDEX 1 TO 5. import java.util.Scanner; class GettingUniCodeValues{ public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("Enter a string:"); String s1 = s.nextLine(); System.out.println("The Unicode values from the given range are = "); for(int i = 1;i <= 5;++i) { System.out.println(s1.charAt(i)+" = " +s1.codePointAt(i)); } } } ================================= codePointBefore(): ================= can accept an index value return a Unicode values of the previous character to the specified index. Syntax: str-obj.codePointBefore(Index) class Unicode{ public static void main(String[] args) { String s = "Hello World!"; System.out.println(s.codePointBefore(5)); } } ==================================== contains(): ========== ==> used to check about the membership of the specified character. Syntax: str.contains("character") class MembershipCheck{ public static void main(String x[]) { String s = "Hello"; System.out.println(s.contains("l")); System.out.println(s.contains("llO")); } } =========================================== // WAP TO COUNT THE NUMBER OF CHARACTERS OF THE STRING WITHOUT length() method. import java.util.Scanner; class StringLnegth{ public static void main(String[] args) { Scanner sco = new Scanner(System.in); System.out.println("Enter the string:"); String s = sco.nextLine(); // Converting the string to the character array char[] ar = s.toCharArray(); int count = 0; for(char a : ar) { count++; } System.out.println("The Total Number of caharacters of the string = "+count); } } ======================================== Assignment: =========== 1) WAP TO REVERSE THE STRING. 2) WAP TO COUNT NUMBER OF VOWELS, CONSONANTS AND DIGITS OF THE STRING. "HELLO123" VOWELS = 2 CONSONANTS = 3 DIGITS = 3