/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test;/** * * @author Administrator */ public class Func { public void matchesTest() { String str = " "; System.out.println(str.matches("[0-9]*"));//false } public static void main(String[] args) { Func f = new Func(); f.matchesTest(); } }
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;/**
*
* @author Administrator
*/
public class Func { public void matchesTest() {
String str = " ";
System.out.println(str.matches("[0-9]*"));//false
} public static void main(String[] args) {
Func f = new Func();
f.matchesTest();
}
}
String str = "";
System.out.println(str.matches("^[0-9]+$"));