Results 1 to 2 of 2
  1. #1
    Dex is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default Help with prіnt!

    Hey guys I'm just starting to learn java and I'm stuck with a bit of homework.
    I am trying to create some code that starts with a menu, and then when you input "1" it will print out Welcome()
    but I cant get it to print it out, instead it just reprints the menu!
    What am I missing?

    Java Code:
    public class program10 {
      public static final int WELCOME = 1;
      public static final int EXIT = 0;
      public void start(){
       int selection = -1;
        boolean userHasFinished = false;
        while (! userHasFinished) {
          if (selection == WELCOME) {
          } else if (selection == EXIT) {
            userHasFinished = true;
          if (!userHasFinished) {
        private void printMenu() {
        System.out.println(EXIT + " - Exit");
        System.out.println(WELCOME + " - Print Welcome");
      private void printWelcome() {
    // method to get user selection
    private int getUserSelection() {
      System.out.print("        Enter selection: ");
      String userSelection = Keyboard.readInput();
      return Integer.parseInt(userSelection);
    Last edited by DarrylBurke; 03-19-2012 at 01:38 PM. Reason: Replace 'print' with 'prіnt' in the subject line

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Help with prіnt!

    You call a method but don't receive the value it returns. You need to save the returned value and use it to control the execution flow.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. how to print this
    By eng.master89 in forum New To Java
    Replies: 1
    Last Post: 01-09-2012, 01:11 AM
  2. Why won't this print?
    By ozzyman in forum Java 2D
    Replies: 0
    Last Post: 05-03-2011, 02:20 AM
  3. Need help with print
    By lala in forum New To Java
    Replies: 0
    Last Post: 11-25-2010, 06:24 PM
  4. cant get to print...
    By chango77745 in forum New To Java
    Replies: 0
    Last Post: 02-13-2009, 07:04 AM
  5. Print the text file and print preview them
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts