Home / Programs / Write a java program to count a number of Unicode code points in the specified text range of a String.
🚀 Programming Example

Write a java program to count a number of Unicode code points in the specified text range of a String.

👁 1,689 Views
💻 Practical Program
📘 Step Learning
Write a java program to count a number of Unicode code points in the specified text range of a String.

💻 Program Code

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);
  }
}

                        

🖥 Program Output

Original String : atnyla.com
Codepoint count = 9
Press any key to continue . . .
                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

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.

🔥 Practice suggestion

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.