public class Exercise {
public static void main(String[] args) {
String str = "atnyla.com";
System.out.println("Original String : " + str);
// codepoint from index 1 to index 10
int ctr = str.codePointCount(1, 10);
// prints character from index 1 to index 10
System.out.println("Codepoint count = " + ctr);
}
}
Original String : atnyla.com
Codepoint count = 9
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.