Ok, So I have this simple code: String s = "9"; int i = 9; int k = i + Integer.intValue(s); ======== Now shouldn't Integer.intValue convert String s to a primitive so it can add it to i? Instead Java finds java.lang.String instead of int. What's the logic behind this?
Joined: Mar 07, 2003
intValue is an instance method not static. Doing this should work:
SCJP 1.4<br />SCWCD 1.4
Joined: Dec 05, 2003
Another possibility is Integer.parseInt which avoids creating the extra Integer object:
[ December 13, 2003: Message edited by: Don Wood ]