运行时出错了,报错信息"could not find the main class.program will exit." 原代码: public class B { public static void main(String[] args) { String str = "2007-9-8 安放地方 十分"; // 方括号内是一个半角空格和一个全角空格 String[] strs = str.split("[ ]+"); for(String s : strs) { System.out.println(s); } }}
不可能吧。不是程序的错误,那你直接在 main 方法里打个 System.out.println("BBB"); 一个语句看看会出错吗?
不行啊!String s : strs报错啊!可能和我用的eclipse版本有关吧!还有没有其他的写法啊?谢了!
// 方括号内是一个半角空格和一个全角空格
String[] strs = str.split("[ ]+");
for(String s : strs) {
System.out.println(s);
}
原代码:
public class B { public static void main(String[] args) {
String str = "2007-9-8 安放地方 十分";
// 方括号内是一个半角空格和一个全角空格
String[] strs = str.split("[ ]+");
for(String s : strs) {
System.out.println(s);
}
}}
System.out.println(strs[i]);
}就可以了。