• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

http statement in Java.......:S  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am new to this forum. I happened to come acroos the below code snippet and tried executing it.

class sample {
public static void main(String[] args) {
System.out.print("iexplore pen");
http://www.google.com;
System.out.println(":maximise");
}
}

It is compiling successfully and the output is normal. How does this compile?? How does JVM interpret the http statement?? Any significant reason that this sort of statement is allowed in the middle of the program??

Please note that the above code snippet does not compile if you remove the last print statement, I mean, leaving the http statement as the last statement.

Thanks and regards,
Anitha
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anitha,
Welcome to Java Ranch...Not only "http:",try anitha:,ramesh:.The compiler treats them as labels...So it compiles fine...
http:->Label
//www.google.com ->comment
Hope...it clarified your doubt....
[ March 21, 2008: Message edited by: Laxman Guru ]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup to add to the explanation if i have code like:


It doesn't compile..because after a label (http: is a label), some piece of code is required.
 
CAAnitha Ramesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you for the very clear explanation.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!