#Anyone know why my vararg method wont accept multiple Strings?

12 messages · Page 1 of 1 (latest)

wary notch
#
    public int getMenultem(String...options) {
        String[] menuList = {"1 - Encrypt text", "2 - Decrypt text", "3 - Display ecrypted list", "4 - Exit"};
        boolean loop = true;
        int x =0;
        
        do {
            for (String list : menuList) {
                System.out.println(menuList[x++]);
            }
            x=0;
            System.out.print("Enter value: ");
            if (keyboard.hasNextInt()) {
                userInput = keyboard.nextInt();
                if (userInput > 0 && userInput < 5) {
                    System.out.println(userInput);
                    loop = false;
                } else {
                    System.out.println("\nPlease enter an integer within range");
                }
            } else {
                System.out.println("\nPlease enter an integer");
                keyboard.next();
            } 
        } while (loop);
        
        return 0;
    }
    
    public String getString(String prompt) {
        return prompt;
    }
    
    public int getInt(String prompt, int min, int max) {
        return 0;
    }
    
    public Encryptable getMethod() {
                //This does not work!!!!
        int x = getMenuItem("1 - Encrypt text", "2 - Decrypt text", "3 - Display ecrypted list", "4 - Exit");
        
    }
vagrant sirenBOT
#

This post has been reserved for your question.

Hey @wary notch! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

barren bough
#

what do you mean by "does not work"

wary notch
barren bough
#

ah

#

public int getMenultem(...) {...}
int x = getMenuItem(...);

#

look at the names very closely

wary notch
#

i love you

#

close

#

thank you for your help

vagrant sirenBOT
# wary notch thank you for your help

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.