DIGIT-ARC read-only archive · snapshot: July 23, 2026

':' turning into label statement

14 posts · originally from https://geek.digit.in/community/threads/turning-into-label-statement.79600/

redhat
redhat Original post #1
Feb 3, 2008 at 7:00 PM
I use the BlueJ compiler to write and run Java programmes.
(I'm in school, n d board prescribes that :p)
While writing a program, i experianced an unusual error, whenever I type ":", it turns into a label statement, and I cant use it for declaring cases in Switch...

Code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/**
 * Write a description of class Designs here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Designs
{

    public static void main(String[] args) throws IOException
    {
        boolean cont = true;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        do
        {
            loop:cont = true;
            System.out.println("/fWelcome to the Designs Class...");
            System.out.println("01. Design 01");
           
            System.out.print("Please Select an option : ");
            try
            {
                int opt = Integer.parseInt(br.readLine());
            }
            catch(Exception oe)
            {
                System.out.println("Error in input :/n" + oe);
                break;
            }
            Switch(opt);
            {
                case 1:
                System.out.println();
                default:
                break loop;
            }
        } while(cont);
    }
}
PS I have removed some parts of the code.

ERROR:
Code:
Designs.java:46: orphaned case
                case 1:
                ^
Designs.java:48: orphaned default
                default:
                ^
2 errors

Can someone please help?

THREAD CLOSED...​

Sorry, I found my error:
I was referencing to variable opt, which was out of scope
Its limited to the try block...:rolleyes:
redhat
redhat #4
Feb 3, 2008 at 7:54 PM
OK,
Mods PLEASE close this thread.....
Faun
Faun #6
Feb 3, 2008 at 10:53 PM
+1
still
Pathik
Pathik #7
Feb 3, 2008 at 11:13 PM
+1
Me bhi karunga. me bhi karunga.. :lol:
Faun
Faun #9
Feb 3, 2008 at 11:46 PM
while(true)
{

call(mods, close_the_thread);
sleep(MAX)

};
MetalheadGautham
Feb 4, 2008 at 12:09 AM
while(true)
{

call(mods, close_the_thread);
sleep(MAX)

};
make it
Code:
getorder();
while(true())
 {
   if(need=={close})
    {
      call(mods, close_the_thread);
    }


   else
    {
      sleep(MAX);
      break();
    }

}
Faun
Faun #11
Feb 4, 2008 at 12:11 AM
make it
Code:
getorder();
while(true())
 {
   if(need=={close})
    {
      call(mods, close_the_thread);
    }


   else
    {
      sleep(MAX);
      break();
    }

}

KIS :D

why do u put break after sleep ? bad...bad... pgming