My java code has an obvious error. Why does it compile and run?
public class HelloWorld {
public static void main (String args[]){
System.out.println ("Hello ");
http://www.google.com
System.out.println ("World!");
}
}
The above code is just compiling and executing fine. Why the c开发者_Python百科ompiler is not reporting any error?
The http: is a Label Statement. See here also.
The //www.google.com portion is then interpreted as a // comment.
Because http: it consider it as label and then rest part are under comment
Basic Usage of Label :
label1:
for(){
label2:
for(){
if(condition1)
break label1;//break outerloop
if(condition2)
break label2;//break innerloop
}
}
- Sun Official Document Describing Label
加载中,请稍侯......
精彩评论