- 通过下标获取
String number = "2563.2154";
int index = number.indexOf(".");
String intNumber = number.substring(0,index);
System.out.println("测试1:"+intNumber);
- 截取字符串的方式
String number = "2563.2154";
System.out.println("测试2:"+number.split("\.")[0]);
String number = "2563.2154";
int index = number.indexOf(".");
String intNumber = number.substring(0,index);
System.out.println("测试1:"+intNumber);
String number = "2563.2154";
System.out.println("测试2:"+number.split("\.")[0]);