File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes http statement in Java.......:S Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "http statement in Java.......:S" Watch "http statement in Java.......:S" New topic

http statement in Java.......:S

CAAnitha Ramesh

Joined: Mar 20, 2008
Posts: 3
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");;

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,
Laxman Guru

Joined: Feb 26, 2008
Posts: 17
Hi Anitha,
Welcome to Java Ranch...Not only "http:",try anitha:,ramesh:.The compiler treats them as labels...So it compiles fine...
// ->comment clarified your doubt....
[ March 21, 2008: Message edited by: Laxman Guru ]

An Sush
Ranch Hand

Joined: Jan 17, 2007
Posts: 47
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

Joined: Mar 20, 2008
Posts: 3
Thanks to both of you for the very clear explanation.
I agree. Here's the link:
subject: http statement in Java.......:S
It's not a secret anymore!