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 8 of 8

Thread: [Newbie] Method will not execute.

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default [Newbie] Method will not execute.

    Solved. Thanks
    Last edited by parkBENch; March 18th, 2012 at 05:24 PM.


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: [Newbie] Method will not execute.

    Where is the main() method?
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: [Newbie] Method will not execute.

    Sorry, here it is.
    Last edited by parkBENch; March 18th, 2012 at 05:24 PM.

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: [Newbie] Method will not execute.

    And where is getUserSelection()?
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  5. The Following User Says Thank You to Mr.777 For This Useful Post:

    parkBENch (March 16th, 2012)

  6. #5
    Junior Member
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: [Newbie] Method will not execute.

        private int getUserSelection() {
            System.out.print("        Enter selection: ");
            String userSelection = Keyboard.readInput();
            return Integer.parseInt(userSelection);
        }

  7. #6
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: [Newbie] Method will not execute.

    So, this function returns an integer. In your above code where you store the returning value?
    In your code you are actually doing this;
    getUserSelection();
    which means you discard the returned value. selection variable still has -1 in it's value. Use this;
    selection = getUserSelection();
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  8. The Following User Says Thank You to Mr.777 For This Useful Post:

    zipstacrack (March 16th, 2012)

  9. #7
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: [Newbie] Method will not execute.

    First off, don't feel bad about it not executing properly, that was the universities fault - a logic error on their part.
    The assessment worked wrong like that.

    Mr.777 provided what the code SHOULD have looked like.

    Well, good work on starting the assessment already. If this wasn't an error on their part this would be breaching the rules searching for help else where but oh well.

    See you in compsci101 - even though I don't know who you are.
    Last edited by zipstacrack; March 16th, 2012 at 09:18 PM.

  10. #8
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: [Newbie] Method will not execute.

    Well, good work on starting the assessment already. If this wasn't an error on their part this would be breaching the rules searching for help else where but oh well.
    parkBENch didn't ask for the code by the way. I don't know if it's university's task or OP\'s personal. OP asked for the help, we are here to help and also we don't do homework for others.
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

Similar Threads

  1. Struts2 without execute method
    By tcstcs in forum Web Frameworks
    Replies: 3
    Last Post: May 29th, 2013, 07:24 AM
  2. execute a method over a maximum period of time
    By PedroCosta in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 24th, 2011, 02:06 PM
  3. Could not execute the file
    By miaaa00 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 20th, 2011, 08:28 AM
  4. how to execute a simple display without a main method
    By chronoz13 in forum Java Theory & Questions
    Replies: 5
    Last Post: January 13th, 2010, 07:28 AM
  5. Replies: 6
    Last Post: October 20th, 2009, 06:33 AM