public class Exercise2 {
public static void main(String[] args) {
String str = "atnyla.com";
System.out.println("Original String : " + str);
// codepoint before index 1
int val1 = str.codePointBefore(1);
// codepoint before index 9
int val2 = str.codePointBefore(9);
// prints character before index1 in string
System.out.println("Character(unicode point) = " + val1);
// prints character before index9 in string
System.out.println("Character(unicode point) = " + val2);
}
}
Original String : atnyla.com
Character(unicode point) = 97
Character(unicode point) = 111
Press any key to continue . . .
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.