PDA

View Full Version : ':' turning into label statement


redhat
03-02-2008, 07: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...


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:

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:

The_Devil_Himself
03-02-2008, 07:15 PM
THREAD CLOSED...




no it isn't.:D

MetalheadGautham
03-02-2008, 07:43 PM
no it isn't.:D
+1 :lol:

redhat
03-02-2008, 07:54 PM
OK,
Mods PLEASE close this thread.....

Cyclone
03-02-2008, 08:24 PM
+1 :lol:

1 more!

Sorry, I just couldn't resist!:razz:

T159
03-02-2008, 10:53 PM
+1
still

Pathik
03-02-2008, 11:13 PM
+1
Me bhi karunga. me bhi karunga.. :lol:

Garbage
03-02-2008, 11:18 PM
no it isn't.:D
post++ :D

T159
03-02-2008, 11:46 PM
while(true)
{

call(mods, close_the_thread);
sleep(MAX)

};

MetalheadGautham
04-02-2008, 12:09 AM
while(true)
{

call(mods, close_the_thread);
sleep(MAX)

};
make it

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


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

}

T159
04-02-2008, 12:11 AM
make it

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

MetalheadGautham
04-02-2008, 12:15 AM
KIS :D
depends on weather you are a guy or a girl :p
why do u put break after sleep ? bad...bad... pgming
mine was C++. Sleep was to help us leave this forum :lol:.

T159
04-02-2008, 12:21 AM
depends on weather you are a guy or a girl :p

mine was C++. Sleep was to help us leave this forum :lol:.
KIS = Keep it simple

MetalheadGautham
04-02-2008, 12:25 AM
KIS = Keep it simple
that was a joke:D