First Assignment and already stuck....Newbie Question
Hey guys, I'm brand new to java and already encountering an issue while trying to do my first assignment in BlueJ. I'm just trying to get to print off the name in the second object but it only prints "null" when I run the second object. I run the first object to input the name and when i want to have the greeting with the name returned in the 2nd object it gives me 'null'. Help please, and I'm really really really sorry for posting this, but I'm on this for several hours and can't get it. PLease please please help.....
import javax.swing.*;
// Assignments to demonstrate objects, fields, input and output.
public class Greeter {
private String name;
// Ask the user for a name in a Swing dialog.
public void askValueDialog() {
String name;
name = JOptionPane.showInputDialog("Please enter a new value.");
}
public void greetDialog() {
JOptionPane.showMessageDialog(null, "The current value is " + name);
}
}