在JAVA中,用什么类型可以表示第一个字是0的数,如070108

来源:百度知道 编辑:UC知道 时间:2024/06/03 15:47:35

用String ,如:

public class Test {

public static void main(String[] args) {
String a = "070108" ;
Integer i = Integer.valueOf(a) ;
System.out.println(a) ;
System.out.println(i) ;
}
}
测试结果:
070108
70108

String 类型

public class Test {

public static void main(String[] args) {
String a = "070108" ;//你也可以换别的数
if(a.indexOf("0")==0)
System.out.println("这个数是以'0'开头的")else
System.out.println("这个数不是以'0'开头的")
}
}