Re: Converting a string to an integer



On Mar 26, 10:41 am, jt <jt_printer_...@xxxxxxxx> wrote:
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.

.



Relevant Pages

  • Re: Parsing large amounts of data (200,000 entries) with XML?
    ... The tag is used to make sure all white space is displayed as ... by specifying a default character set. ... I messed with the browser settings for making fonts ...
    (microsoft.public.vb.general.discussion)
  • Re: output problem
    ... This line reads characters from stdin and stores ... When it finds a non-white character, ... Just as with the first scanf(), ... amount of white space from the input. ...
    (comp.lang.c)
  • Re: Remove white spaces above characters in VB
    ... The white space at the top is actually part of each character cell. ... However, I do know that in the past there have been problems with FontTransparent on some versions of VB and / or some printers, but I thought this was fixed by the time we got to Service Pack 5. ... Private Const TRANSPARENT = 1 ...
    (comp.lang.basic.visual.misc)
  • Re: (Probably simple) problem with displaying Unicode characters
    ... Right now I'm simply trying to display a Unicode character in the ... public static void mainthrows UnsupportedEncodingException { ...
    (comp.lang.java.programmer)
  • Re: Word 2004 and random Hidden characters
    ... are apparently some passages of text which have the hidden character ... 'clear formatting' doesn't remove the hidden attribute). ... Open that in Word 2003, save as RTF, copy to Mac, open in Word 2004 ... white space characters show up as '??' ...
    (microsoft.public.mac.office.word)