0

Creating a text based game. I have a method for each of the following: Race, profession, name.
So for instance:

public static void main(String[] args) {
        // TODO code application logic here
        intro();
        name();
        System.out.println("Welcome " + name);
    }

    public static void String name(){
        System.out.println("Enter Name:");
        String name = sc.next();
        return name;
    }

Yet I get an error when using the name variable in my print in main. Why?

2
Contributors
5
Replies
14
Views
3 Years
Discussion Span
Last Post by Reapt
0

maybe try declaring name = name(); Is it the actual name variable that is causing issues?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.