Variable problems
From: Jeffrey Spoon (JeffreySpoon_at_hotmail.com)
Date: 03/29/05
- Next message: Peter Kirk: "Re: Variable problems"
- Previous message: Max010: "Re: java.lang.NullPointerException"
- Next in thread: Peter Kirk: "Re: Variable problems"
- Reply: Peter Kirk: "Re: Variable problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Mar 2005 12:02:58 +0100
Hello, I have a problem and I'd like to know what causes it. I've
extracted the relevant method into a class. Basically I'd like to know
why addUserSQL outputs INSERT INTO users VALUES (null,0) instead of
INSERT INTO users VALUES (hellomum,1234567890)
The simple solution would be to move the String into the method but
there's a lot of them and it looks fairly untidy. Also I'm curious as to
what I'm doing wrong.
Code:
public class Test {
public static void main(java.lang.String[] args) {
Test tst = new Test();
tst.addUser("hellomum", 1234567890);
System.out.println("addUsermain: " + tst.addUserSQL);
}//main
public void addUser(String username, long ipAddress) {
//
this.ipAddress = ipAddress;
this.username = username;
//**debug
System.out.println("ipAddress = " + ipAddress);
System.out.println("username = " + username);
//**debug
System.out.println("addUser: " + addUserSQL);
//**
}//addUser
//attribs
String username;
long ipAddress;
String addUserSQL = "INSERT INTO users VALUES (" + username +
"," + ipAddress + ")";
}//test
-- Jeffrey Spoon
- Next message: Peter Kirk: "Re: Variable problems"
- Previous message: Max010: "Re: java.lang.NullPointerException"
- Next in thread: Peter Kirk: "Re: Variable problems"
- Reply: Peter Kirk: "Re: Variable problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]