Label is always attached with a statement. So, when you are trying to use "uselesslabel:" a label without a statement, it will give you errors...
Shalini Srivastav
Ranch Hand
Joined: Jul 21, 2012
Posts: 86
posted
0
You are not correct.
Gaurangkumar Khalasi
Ranch Hand
Joined: Jun 02, 2012
Posts: 186
posted
0
Shalini Srivastav wrote:You are not correct.
You got an error??? Or What are you trying to say?
Shalini Srivastav
Ranch Hand
Joined: Jul 21, 2012
Posts: 86
posted
0
I don't know what did you mean by statement.
Gaurangkumar Khalasi
Ranch Hand
Joined: Jun 02, 2012
Posts: 186
posted
0
A statement in Java forms a complete command to be executed and can include one or more expressions.
or
A statement is a single "command" that is executed by the Java interpreter.
Different kinds of statements in java for example:
1). Declaration Statement (e.g. int value;)
2). Expression Statement (e.g. value=7;)
3). Control flow Statement (e.g. for(int i=0; i<10;i++) {} )
4). Null Statement (e.g. ; )
I am surprised how a topic which is not used at all in the Java world could ignite such a discussion. In OCPJP, labels are there only for the questions with labelled break. Application wise, labels are never used at all. This is a migration from C's jump statements.
Also Shalini, Gaurang's code is correct
This code runs and outputs the String inside the println.
The error is due to improper ending(without the semicolon) which actually makes the the closing bracket as a statement which is clearly an error and this is stated very specifically when you do a javac on the class file.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.