How to use the Character class
Character: Character type
1, attributes.
static int MIN_RADIX: Returns the minimum radix.
static int MAX_RADIX: Returns the maximum radix.
static char MAX_VALUE: The maximum value of character type.
static char MIN_VALUE: Minimum value of character type.
static Class TYPE: Returns the current type.
2、Constructor.
Character(char value): Construct a Character object with char parameters.
3. Method.
Instructions:
1. All methods are public;
2. Writing format: [Modifier]
Such as :
static int parseInt(String s) means: This method (parseInt) is a class method (static), the return type is (int), and the parameters required by the method are of type String.
1. char charValue(): Returns the value of the character object.
2. int compareTo(Character anotherCharacter): Compare the current Character object with anotherCharacter. The equality relationship returns 0; the less than relationship returns a negative number; the greater than relationship returns a positive number.
3. int compareTo(Object o): Compare the current object with another object. If o is a Character object, it has the same function as 2; otherwise, a ClassCastException is thrown.
4. static int digit(char ch, int radix): Returns the decimal value of the current character according to the base. If Character.MIN_RADIX Code:
System.out. print ln("Character.MIN_RADIX: " + Character.MIN_RADIX ); System.out.println("Character.MAX_RADIX: " + Character.MAX_RADIX ); System.out.println("Character.digit('2',2): " + Character.digit('2',2) ); System.out.println("Character.digit('7',10): " + Character.digit('7',10) ); System.out.println("Character.digit('F',16): " + Character.digit('F',16) );
The result is:
Character.MIN_RADIX: 2 Character.MAX_RADIX: 36 Character.digit('2',2): -1 不是有效值。 Character.digit('7',10): 7 Character.digit('F',16): 15
5. boolean equals(Object obj): Compare with objobject. Returns "true" if and only if obj is not "null" and is consistent with the current Character
object.
6. static char forDigit(int digit, int radix): Determine the character represented by the current value based on a specific base. The inverse operation of 4, returns "'\u0000'" if the value is illegal.
Code:
System.out.println("Character.MIN_RADIX: " + Character.MIN_RADIX ); System.out.println("Character.MAX_RADIX: " + Character.MAX_RADIX ); System.out.println("Character. for Digit(2,2): " + Character.forDigit(2,2) ); System.out.println("Character.forDigit(7,10): " + Character.forDigit(7,10) ); System.out.println("Character.forDigit(15,16): " + Character.forDigit(15,16) );
The result is:
Character.MIN_RADIX: 2 Character.MAX_RADIX: 36 Character.forDigit(2,2): Character.forDigit(7,10): 7 Character.forDigit(15,16): f
7. static int getNumericValue(char ch): Returns the numerical value of character ch.
8. static int getType(char ch): Returns the type of character. Please check the Java documentation for specific types.
9. int hashCode(): Returns the hash table code of the current character.
10. static boolean isDefined(char ch): Determine whether the character ch is clearly defined in the Unicode character set.
11. static boolean isDigit(char ch): Determine whether the character ch is a number.
12. static boolean isIdentifierIgnorable(char ch): Determine whether the character ch is an ignorable character in the Unicode character set.
13. static boolean isISOControl(char ch): Determine whether the character ch is a control character in the ISO standard.
14.static boolean isJavaIdentifierPart(char ch): Determine whether the character ch is a partial identifier in Java.
15. static boolean isJavaIdentifierStart(char ch): Determine whether the character ch is the first identifier in Java.
16. static boolean isLetter(char ch): Determine whether the character ch is a letter.
17. static boolean isLetterOrDigit(char ch): Determine whether the character ch is a letter or number.
18. static boolean isLowerCase(char ch): Determine whether the character ch is a lowercase letter.
19. static boolean isMirrored(char c): Determine whether the character c has a character in the opposite direction according to the Unicode table. For example: "[" has "]" in the opposite direction, and the result is: true.
20. static boolean isSpaceChar(char ch): Determine whether the character ch is a space in Unicode.
21. static boolean isUpperCase(char ch): Determine whether the character ch is an uppercase letter.
22. static boolean isWhitespace(char ch): Determine whether the character ch is a null character in Java definition.
Code:
Including:
char c1 = '\u0009';//水平列表符 char c2 = '\u000A';//换行 char c3 = '\u000B';//垂直列表符 char c4 = '\u000C';//换页 char c5 = '\u000D';//回车 char c6 = '\u 001 C';//文件分隔符 char c7 = '\u001D';//组分隔符 char c8 = '\u001E';//记录分隔符 char c9 = '\u001F';//单元分隔符
23. static char toLowerCase(char ch): Convert whether ch is lowercase.
24. String toString(): Convert the current Character object into a string.
25. static String toString(char c): This is a class method that converts c into a string.
26. static char toUpperCase(char ch): Convert whether ch is uppercase.
Code:
System.out.println("Character.toUpperCase('q'): " + Character.toUpperCase('q') ); System.out.println("Character.toLowerCaseCase('B'): " + Character.toLowerCase('B') );
The result is:
Character.toUpperCase('q'): Q Character.toLowerCaseCase('B'): b
[Related recommendations]
2. Detailed explanation of the differences between Character and char methods
3. Explain in detail the Character class in Java
4. Instance analysis of the packaging class Character
5. About the usage analysis of Character class
The above is the detailed content of Detailed explanation of examples of Character class. For more information, please follow other related articles on the PHP Chinese website!

Start Spring using IntelliJIDEAUltimate version...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Java...

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software