
java determines whether it is a number:
int id = 12345689797;
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(id);
if( !isNum.matches() ){
//不是数字
}else{
//是数字
}matches() method is used to detect whether a string matches a given regular expression.
Syntax
public boolean matches(String regex)
Parameters
regex -- Regular expression that matches strings.
Return value
Returns true when the string matches the given regular expression.
For more java knowledge, please pay attention to java basic tutorial.
The above is the detailed content of Java verifies whether it is a number. For more information, please follow other related articles on the PHP Chinese website!

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

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

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

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





