Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: switch statement

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default switch statement

    class murderer{
    	public static void main(String args[])
    	{
    	int age;
    	age = 3;
     
    	switch (age)
    	{
    	case 1:
    		System.out.println("You can't kill");
    		break;
    	case 2:
    		System.outprintln("You can talk");
    		break;
    	case 2:
    		System.outprintln("You can get in trouble");
    		break;
    	default:
    		System.out.println("You can go to hell");
    	break;
    			}
    		}
    	}

    What's wrong with it?


  2. #2
    Member Staticity's Avatar
    Join Date
    Jul 2011
    Location
    Texas
    Posts
    105
    My Mood
    Inspired
    Thanks
    3
    Thanked 5 Times in 5 Posts

    Default Re: switch statement

    I feel extremely reluctant to respond to this thread.. *sighs*

    Have you looked over your code? I suggest you re-look it over. For a pointer, your issue is not a logical error, but a careless mistake...

    Advice for later posts: Don't be so blunt by asking:

    "What's wrong with it?".

    State your issue, what you've tried, and what you think you could do to fix it.. G'luck
    Simplicity calls for Complexity. Think about it.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: switch statement

    Never mind I just made some typos. Fixed now.
    The typos were in System.outprintln and I made 2 same cases.

    Hahaha so funny to read post of an elder who is tired of noobs like me
    I apologize.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: switch statement

    Quote Originally Posted by Tank314 View Post
    Never mind I just made some typos. Fixed now.
    The typos were in System.outprintln and I made 2 same cases.

    Hahaha so funny to read post of an elder who is tired of noobs like me
    I apologize.
    It has nothing to do with being 'tired of noobs'...it has to do with phrasing a question in the appropriate manner. Suggested reading: http://www.javaprogrammingforums.com...-get-help.html

  5. #5
    Member Staticity's Avatar
    Join Date
    Jul 2011
    Location
    Texas
    Posts
    105
    My Mood
    Inspired
    Thanks
    3
    Thanked 5 Times in 5 Posts

    Default Re: switch statement

    Quote Originally Posted by Tank314 View Post
    Hahaha so funny to read post of an elder who is tired of noobs like me
    I apologize.
    I'm a High School Student buddy. Thanks for the support copeg.
    Simplicity calls for Complexity. Think about it.

Similar Threads

  1. How to Use the Java switch statement
    By JavaPF in forum Java Programming Tutorials
    Replies: 6
    Last Post: April 18th, 2013, 05:19 PM
  2. Advancing day w/ if/else & switch statement
    By rbread80 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 31st, 2010, 10:43 PM
  3. help with switch statement
    By robertsbd in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 12th, 2010, 12:52 PM
  4. How to Use the Java switch statement
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 5
    Last Post: October 8th, 2009, 09:00 PM
  5. [SOLVED] Switch statement question
    By shikh_albelad in forum Loops & Control Statements
    Replies: 5
    Last Post: May 31st, 2009, 05:13 AM