This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes setPriority() and labels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "setPriority() and labels " Watch "setPriority() and labels " New topic

setPriority() and labels

Ranch Hand

Joined: Nov 22, 2001
Posts: 110
hi all ,

as i m solving sun_guoqiao mocks a very confusing quest comes
tht is:-
public class Test052
public static void main(String args[])
int i;
for( i=0; ; ++i) {
if( i > 3 ) break; //1
int k = 0;
labelA: { //2
if(k > 0) break labelA;
labelA: { //3
if(k < 0) break labelA;
its explanation said tht labels named can be used as long as the overlapp....
plz make me understand.wht she tried to say?
Other thing is :--
public class T002 extends Thread
public static void main(String args[])
T002 t = new T002();
System.out.print(t.getPriority() + " ");
t.setPriority(1); //1
System.out.println(t.getPriority()); //2
this question explanation said tht setPriority() should be uses in order to have some effect ...
i can't undersatnd the above explanation as it also have effect of setPrioirty() before the start() method.
plz help me............

Muhammad Hussain<br />Sun Certified Java Programer (SCJP2)<br />Sun Certified Web Component Devloper SCWCD
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Muhammad,
With out seeing the sentence, I can't say what someone was trying to say. I can however, explain it myself. You seem to be having an issue with the statement labels.
In java, labels are statement specific and not program specific as in C or other languages. What does that mean? Well, it means that the label is only in effect for a single statement. In the case of your example the statement is enclosed in braces:

Once I get out of the statement labelA is no longer a valid label. Therefore I can make use of the same label in another statement.
I can't re-use a valid label while it is valid (i.e., inside its' own statement). Therefore I will get a compiler error trying the following.

Ranch Hand

Joined: Nov 22, 2001
Posts: 110
thankx sir i m gratefull to Manfred Leonhardt..
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: setPriority() and labels
Similar Threads
Cannot understand the flow of code...
Thread------ getPriority.
Flow Control
setPriority(int i) method of Thread
Can you expailn me the flow..