I am testing out the NetBeans IDE for Java and other languages, and it is going quite well. Now, for the program, I am asking the user to enter their name, but I can't figure out how to initialize the variable. Here is the code.
public class Main {
//Variables
String word = "";
public void getName()
{//Ask user for their name
System.out.print("Please enter your name: ");
String name = name;
}//getName
public void displayName()
{//Display user's name
System.out.println("Hello, " + name);
}//displayName
public static void main(String[]args)
{//main
Main program = new Main();
program.getName();
program.displayName();
}
}
I just need to figure out how to input information into Java. I used to use blueJ and I did it via the "In" class, but NetBeans doesn't have it.