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 |
The " ^ " symbol in Java represents the XOR logical operator, which performs a logical exclusive OR operation between two boolean values. If one of the operands is true and the other is false, this operator returns true; otherwise, it returns false. The XOR operator is...
3 min read
What is .NET? Microsoft's .NET framework is an open-source framework geared toward Microsoft product consumers. The framework was designed specifically for Microsoft when it was initially released in 2002. That implies you won't be able to code or execute produced apps on Linux, Android, or iOS. It was...
3 min read
How to convert byte array to String in Java? The process of converting a byte array to a String is called decoding. This process requires a Charset. Though, we should use charset for decoding a byte array. There are two ways to convert byte array to String: By using...
7 min read
In this section, we will learn how to swap first and last digit of a number. Step 1: Read the integer input from the user. The first step is to read an integer input from the user. We can use the Scanner class to achieve this. Here's...
4 min read
Differences Between this and super in Java In Java, the keywords super and this are essential for interacting with classes and objects. In addition to referring class members, they assist in managing inheritance. Java also provides this() and super() constructors that are used in the constructor...
7 min read
The natural numbers are the numbers that include all the positive integers from 1 to infinity. For example, 1, 2, 3, 4, 5, ......, n. When we add these numbers together, we get the sum of natural numbers. In this section, we will create the following programs: Java...
3 min read
Java programming language requires variables to operate and handle data. Java creates several variables as per data format and data types. The variable declaration means creating a variable in a program for operating different information. The Java variable declaration creates a new variable with required properties....
5 min read
Image processing is a fascinating field within computer science, encompassing a wide range of operations for analyzing and manipulating images. One of the most basic yet intriguing tasks in image processing is generating an image with randomly colored pixels. This task can serve as an...
4 min read
Variables are an essential part of data storage and manipulation in the realm of programming. In addition to making values available within a programme, they offer a means of holding them temporarily. Not all variables, though, are made equally. Each variable has a scope that specifies...
3 min read
Applications in modern times need excellent concurrency management as well as the ability to scale and rapid reaction capabilities. Judging by contemporary application requirements, Reactive Programming established itself as a solution that operates with asynchronous data streams. This approach permits applications to work with real-time events without...
5 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