Java Character.isSurrogate() Method8 May 2025 | 3 min read In Java, the Character.isSurrogate() function determines if a specified character is a surrogate character. Surrogate pairs in UTF-16 encoding represent characters that are beyond the Basic Multilingual Plane (BMP). These pairs consist of high surrogates and low surrogates. A character is deemed a surrogate code unit if it meets the criteria to be categorized as either a low surrogate or a high surrogate. High surrogates range from U+D800 to U+DBFF, while low surrogates are found between U+DC00 and U+DFFF. Syntax: Parameter: ch - the character to check. Returns: true if the character is a surrogate; false otherwise. Let's see how Character.isSurrogate() method works. Java Character.isSurrogate() Method ExampleProgram 1:This Java program assesses if particular characters are surrogate code units by using the Character.isSurrogate() method. It handles different kinds of characters, including Unicode characters, letters, digits, and symbols, and delivers the appropriate outcomes. Output: Does ? qualify as a surrogate? true Check if c is a surrogate: false Is 8 considered a surrogate? false Verification: Is ? a surrogate character? false Can % be classified as a surrogate? false Program 2:This Java application prompts the user to input a character and checks if it is a surrogate code unit by utilizing the Character.isSurrogate() method. Output: Enter a character to verify if it is a surrogate: A Character 'A' is a surrogate code unit: false Program 3:This Java application verifies whether a specified character is a surrogate code unit by employing the Character.isSurrogate() function and saves the outcome in a boolean variable. It subsequently employs a conditional expression to assess if the character is a surrogate code unit. Output: The character '?' is a surrogate code unit. Next TopicJava Logo |
Difference Between Multithreading, Multitasking, and Multiprocessing in Java When developing applications in Java or working with modern computer systems in general, we often encounter terms such as multitasking, multithreading, and multiprocessing. Although they all involve handling multiple operations simultaneously, they work in different ways and serve...
8 min read
Spiral patterns are a popular concept in computer graphics and can be used to visualize data in a unique and interesting way. In this section, we will explore how to create a spiral pattern of numbers using Java. We will cover the logic behind the...
5 min read
In Java, logging is an important feature that helps developers to trace out the errors. Java is the programming language that comes with the logging approach. It provides a Logging API that was introduced in Java 1.4 version. It provides the ability to capture the log...
8 min read
Java generics introduced the idea of parameterized types, which completely changed how programmers create Java code. Because of this, programming has entered a new era in which Java code is shorter, more adaptable, and type-safe. To accomplish these advantages, several design patterns make use of Java...
10 min read
How to run a Java program in Windows 10 To run a java program in Windows 10, we need first to install Java and then set up the environment variables. To do this, follow the following steps- How to install Java? Step 1) Visit the oracle website and then...
2 min read
At present, Java is widely used by many tech giants. The tech giants are regularly hiring Java developers to fulfill market demand. In exchange for manpower, companies offer a high salary package for that and providing seductive offers. In this section, we will discuss the roles...
6 min read
Object-oriented programming has four pillars that are an abstraction, polymorphism, encapsulation, and inheritance. In this section, we will discuss one of them, abstraction. Along with this, we can also learn how to achieve abstraction in Java. Abstraction Abstraction is a feature of OOPs. The feature allows us...
4 min read
Problem Description A matrix consisting of 'm' rows and 'n' columns is shown to you. The purpose is to identify the items that are common to all rows of the matrix. The solution should efficiently return these common elements, considering both time and space complexity. Approach To solve this...
6 min read
The farthest from zero program in Java is a program that finds the element in an array that is farthest from zero. It can be done by calculating the absolute value of each element in the array and returning the element with the largest absolute value....
2 min read
Java operator's precedence refers to the set of rules that dictate the order of evaluation of the different constituents of a given expression. In programming, the use of bitwise operators like XOR (^) and OR (|) is important. So, it is essential to learn how these...
4 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India