import static java.lang.Integer.*;
> public class WillThisWork {
> public static void main(String [] args) {
> String s = "023";
> String y = s.trim();
> Integer x = java.lang.Integer.decode(y);
Integer x = decode(y);
> System.out.println("s as a string is " + s);
> System.out.println("y as a string is " + y);
[quoted text clipped - 15 lines]
> Note: I'm not far enough in the Java Tutorial to answer this question so
> that's the only reason I'm asking you...
http://www.cafeaulait.org/course/week4/31.html
http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html
> Andrew Thompson wrote: a bunch of stuff that I have committed to memory
Wow! I may ask you to repeat it back to me at
some later date, because to be honest, I would
have to reread the thread before I could recall
what I said!
( I Hope I did not use any swear words ;)
..
> ...No whitespace
> characters are permitted in the String.
Uh-huh. I saw something in your code further
down that made me wonder if you had correctly
interpreted what a 'white space character' is.. *
> "leading zero" is the way that octal is represented. I was assuming
> that it was a O (capital letter O) rather than a 0 zero.
Damn, I wish I was using a font that showed
a difference, those O/0 look identical on this
box/config.
> <SSCCE>
> public class WillThisWork {
> public static void main(String [] args) {
> String s = "023";
* the '0' will not be considered a 'white space char.',
the things that would be considered white space might
be summed up as..
<sscce>
import javax.swing.*;
class ShowWhiteSpace {
public static void main(String[] args) {
// sure I've forgotten some..
String untrimmed = "\t 01234Hi! \n\n ";
String trimmed = untrimmed.trim();
JTextArea ta = new JTextArea(
"untrimmed: \t'" + untrimmed + "'\n" +
"trimmed: \t'" + trimmed + "'"
);
JOptionPane.showMessageDialog(null, ta);
}
}
</sscce>
...
> I know that this is probably a silly question, but if I import
> java.lang.Integer.*
Assuming you meant..
import java.lang.Integer.*;
..that is a compilable, but invalid, statement.
The ones that would have the right effect are either ..
import java.lang.Integer;
..or..
import java.lang.*;
The '*' character can import into the namespace,
all classes within a particular package, as done
in the second statement.
The first statement is preferable* though, as
it is an explicit import for the one required
class, and is better documented as a result.
Importing the class (using either form) will
automatically make *all* it's methods available.
* I usually use package imports in SSCCE's,
for the sake of brevity, but it should not
generally be done in 'real' or production
code.
HTH
Andrew T.
jt - 27 Mar 2007 14:10 GMT
>> Andrew Thompson wrote: a bunch of stuff that I have committed to memory
>
[quoted text clipped - 3 lines]
> what I said!
> ( I Hope I did not use any swear words ;)
No, AFAIU it was introduced in 1.0.
Here it is in the *1.5* docs ..
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/
Integer.html#decode(java.lang.String)>
I would have put a link to an even earlier
version of the JavaDocs, but I don't know
of any URL's for the earlier JDocs.
Andrew T.