Determine whether there is Chinese:
public boolean checkcountname(String countname) { Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); Matcher m = p.matcher(countname); if (m.find()) { return true; } return false; }
Determine whether the entire string is composed of Chinese:
public boolean checkname(String name) { int n = 0; for(int i = 0; i < name.length(); i++) { n = (int)name.charAt(i); if(!(19968 <= n && n <40869)) { return false; } } return true; }
Java uses Unicode encoding char type variables The range is 0-65535. The unsigned value can represent 65536 characters. Basically, all characters on the earth can be included.
Chinese characters are basically concentrated between [19968, 40869], with a total of 20901 Chinese characters
unicode encoding range:
Chinese characters: [0x4e00,0x9fa5] (or decimal [19968,40869])
Numbers: [0x30,0x39] (or decimal [48, 57])
Lowercase letters: [0x61,0x7a] (or decimal [97, 122])
Uppercase letters: [0x41,0x5a] (or decimal [65, 90])
For more java knowledge, please pay attention to java basic tutorial.
The above is the detailed content of Java determines whether it is Chinese. For more information, please follow other related articles on the PHP Chinese website!

The article discusses various Java garbage collection algorithms (Serial, Parallel, CMS, G1, ZGC), their performance impacts, and suitability for applications with large heaps.

The article discusses the Java Virtual Machine (JVM), detailing its role in running Java programs across different platforms. It explains the JVM's internal processes, key components, memory management, garbage collection, and performance optimizatio

Java's Nashorn engine enables JavaScript scripting within Java apps. Key steps include setting up Nashorn, managing scripts, and optimizing performance. Main issues involve security, memory management, and future compatibility due to Nashorn's deprec

Java's try-with-resources simplifies resource management by automatically closing resources like file streams or database connections, improving code readability and maintainability.

Java enums represent fixed sets of values, offering type safety, readability, and additional functionality through custom methods and constructors. They enhance code organization and can be used in switch statements for efficient value handling.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.