Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 03-02-2008, 07:00 PM   #1 (permalink)
Mad and Furious
 
redhat's Avatar
 
Join Date: May 2006
Location: Visual Basic 6.0
Posts: 453
Default ':' turning into label statement


I use the BlueJ compiler to write and run Java programmes.
(I'm in school, n d board prescribes that )
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...

Last edited by redhat; 03-02-2008 at 07:00 PM. Reason: Automerged Doublepost
redhat is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 03-02-2008, 07:15 PM   #2 (permalink)
die blizzard die! D3?
 
The_Devil_Himself's Avatar
 
Join Date: Aug 2007
Location: Event horizon
Posts: 2,361
Default Re: ':' turning into label statement

Quote:
Originally Posted by redhat View Post

THREAD CLOSED...

no it isn't.
__________________
Stealing your women and horses since 1843.
The_Devil_Himself is offline  
Old 03-02-2008, 07:43 PM   #3 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,489
Default Re: ':' turning into label statement

Quote:
Originally Posted by The_Devil_Himself View Post
no it isn't.
+1
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is offline  
Old 03-02-2008, 07:54 PM   #4 (permalink)
Mad and Furious
 
redhat's Avatar
 
Join Date: May 2006
Location: Visual Basic 6.0
Posts: 453
Default Re: ':' turning into label statement

OK,
Mods PLEASE close this thread.....
redhat is offline  
Old 03-02-2008, 08:24 PM   #5 (permalink)
Darth Penguin
 
Cyclone's Avatar
 
Join Date: Jun 2007
Location: DarkStar One
Posts: 81
Default Re: ':' turning into label statement

Quote:
Originally Posted by MetalheadGautham View Post
+1
1 more!

Sorry, I just couldn't resist!
__________________
The Force. It surrounds us. It enfolds us. It gets us dates on Saturday Nights.
Cyclone is offline  
Old 03-02-2008, 10:53 PM   #6 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,675
Default Re: ':' turning into label statement

+1
still
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Old 03-02-2008, 11:13 PM   #7 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,772
Default Re: ':' turning into label statement

+1
Me bhi karunga. me bhi karunga..
__________________
My new blog: www.pathikshah.com
Pathik is offline  
Old 03-02-2008, 11:18 PM   #8 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: ':' turning into label statement

Quote:
Originally Posted by The_Devil_Himself View Post
no it isn't.
post++
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 03-02-2008, 11:46 PM   #9 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,675
Default Re: ':' turning into label statement

while(true)
{

call(mods, close_the_thread);
sleep(MAX)

};
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Old 04-02-2008, 12:09 AM   #10 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,489
Default Re: ':' turning into label statement

Quote:
Originally Posted by T159 View Post
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();
    }

}
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is offline  
Old 04-02-2008, 12:11 AM   #11 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,675
Default Re: ':' turning into label statement

Quote:
Originally Posted by MetalheadGautham View Post
make it
Code:
getorder();
while(true())
 {
   if(need=={close})
    {
      call(mods, close_the_thread);
    }


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

}
KIS

why do u put break after sleep ? bad...bad... pgming
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Old 04-02-2008, 12:15 AM   #12 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,489
Default Re: ':' turning into label statement

Quote:
Originally Posted by T159 View Post
KIS
depends on weather you are a guy or a girl
Quote:
Originally Posted by T159 View Post
why do u put break after sleep ? bad...bad... pgming
mine was C++. Sleep was to help us leave this forum .
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is offline  
Old 04-02-2008, 12:21 AM   #13 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,675
Default Re: ':' turning into label statement

Quote:
Originally Posted by MetalheadGautham View Post
depends on weather you are a guy or a girl

mine was C++. Sleep was to help us leave this forum .
KIS = Keep it simple
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is online now  
Old 04-02-2008, 12:25 AM   #14 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,489
Default Re: ':' turning into label statement

Quote:
Originally Posted by T159 View Post
KIS = Keep it simple
that was a joke
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
?using single printf statement to print 2 answers? slugger Programming 8 01-02-2008 03:02 PM
What is a null statement in C language? fun2sh Programming 11 13-07-2007 07:36 PM
Clarification of a Problem Statement... Important. Thor QnA (read only) 1 28-09-2006 07:44 PM
Changing CD Label Hexus QnA (read only) 3 05-11-2004 08:39 PM

 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2