Hi,
I need to have a variable that can be accessed from every method in a class.
Here is what I did (the variable called IPAdresse):
I run this java code with: java FrageClient 192.100.2.100
How to make my execute method read my IPAdresse?
Thanks for any clue!
Andre
I need to have a variable that can be accessed from every method in a class.
Here is what I did (the variable called IPAdresse):
Code:
public class FrageClient extends JFrame implements ActionListener {
String IPAdresse;
...
private void createAndShowGUI(int flag) {
//this method can read the variable entered from main method
System.out.println("IP: " + IPAdresse);
...
}
public FrageClient(String begin, String IPAd) {
IPAdresse = IPAd;
createAndShowGUI(0);
}
public static void main (String args[]) {
new FrageClient("Start", args[0]); // args[0] is the IPAdresse
}
public void execute(String Answer) {
// here is the problem -> IPAdresse comes out null
System.out.println("IP: " + IPAdresse);
}
I run this java code with: java FrageClient 192.100.2.100
How to make my execute method read my IPAdresse?
Thanks for any clue!
Andre