package B;import java.util.Scanner;public class Cen { public static void main(String args[]) {
Scanner sc = new Scanner(System.in); while (true) {
System.out.println("请输入数字:数字*数字这个格式");
String s1 = sc.nextLine();
System.out.println(s1);
String[] s = s1.split("//*"); //我改成"*"为什么就要出现异常??
try {
int i = Integer.valueOf(s[0].trim()) * Integer.valueOf(s[1].trim());
System.out.println("" + i + "\r\n");
} catch (Exception e) {
System.out.println("你输入的格式不正确," + "\r\n");
} }
}
}
Scanner sc = new Scanner(System.in); while (true) {
System.out.println("请输入数字:数字*数字这个格式");
String s1 = sc.nextLine();
System.out.println(s1);
String[] s = s1.split("//*"); //我改成"*"为什么就要出现异常??
try {
int i = Integer.valueOf(s[0].trim()) * Integer.valueOf(s[1].trim());
System.out.println("" + i + "\r\n");
} catch (Exception e) {
System.out.println("你输入的格式不正确," + "\r\n");
} }
}
}
楼主【sure2003】截止到2008-07-13 21:42:04的历史汇总数据(不包括此帖):
发帖的总数量:231 发帖的总分数:9943 每贴平均分数:43
回帖的总数量:198 得分贴总数量:4 回帖的得分率:2%
结贴的总数量:227 结贴的总分数:9853
无满意结贴数:2 无满意结贴分:50
未结的帖子数:4 未结的总分数:90
结贴的百分比:98.27 % 结分的百分比:99.09 %
无满意结贴率:0.88 % 无满意结分率:0.51 %
值得尊敬
有特殊的用途,如果想用 * 来作为拆分的间隔的话,得使用 split("\\*");