My java code has an obvious error. Why does it compile and run?

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