首页上一页 1 下一页尾页 2 条记录 1/1页
Syntax error, 'for each' statements are only available if source level is 1.5 or greater
发表在Java图书答疑
2017-12-05 悬赏:1 学分
《Java从入门到精通(第4版)》第5章 字符串
是否精华
是
否
版块置顶:
是
否
public class Split {
public static void main(String[] args){
String ip = "192.168.0.1";
String[] array1 = ip.split("\\.");
String[] array2 = ip.split("\\.",2);
for(String tmp:array1){
System.out.print("["+tmp+"]");
}
System.out.println();
for(String tmp:array2){
System.out.print("["+tmp+"]");
}
}
}
提示的错误信息为:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error, 'for each' statements are only available if source level is 1.5 or greater
Syntax error, 'for each' statements are only available if source level is 1.5 or greater
at Split.main(Split.java:6)