Article View: aus.computers.java
Article #301Re: Help! String as Integer
From: mitchell
Date: Tue, 16 Jan 2001 07:57
Date: Tue, 16 Jan 2001 07:57
50 lines
2222 bytes
2222 bytes
String a = "yes";
String b = "ls";
int aa = Integer.valueOf("foo").intValue();
int bb = Integer.valueOf("bar").intValue();
System.out.println("" + aa);
System.out.println("" + bb);
try that
Luke Vanderfluit <luke@chipcity.com.au> wrote in message
news:3A63FC90.3C832EFA@chipcity.com.au...
> Hi
>
> I need help with this.
> Why doesn't the following code work?:
> I need to interpret a line of text as an integer.
>
> String a = "yes";
> String b = "ls";
> int aa = Integer.valueOf("foo").intValue();
> int bb = Integer.valueOf("bar").intValue();
> System.out.println(aa);
> System.out.println(bb);
>
> This throws a NumberFormatException
>
> How can I read a String as an Integer
>
> Can you help me please.
>
> Desperate,
> --
> Luke Vanderfluit
>
> Phone 61 8 8556 6112
>
> Aldinga Beach, South Australia
>
>
>
Technical Details
Message-ID:
<979631863.560899@red.hot.net.au>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!newsfeed.cwix.com!intgwpad.nntp.telstra.net!nsw.nnrp.telstra.net!not-for-mailReferences:
<3A63FC90.3C832EFA@chipcity.com.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113ae9,7de64e08ee658586 X-Google-Attributes: gid113ae9,public X-Google-Thread: 10d6db,7de64e08ee658586 X-Google-Attributes: gid10d6db,public X-Google-Thread: 10a146,7de64e08ee658586 X-Google-Attributes: gid10a146,public X-Google-ArrivalTime: 2001-01-15 23:58:03 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!newsfeed.cwix.com!intgwpad.nntp.telstra.net!nsw.nnrp.telstra.net!not-for-mail From: "mitchell" <mitchell@hot.net.au> Newsgroups: aus.computers.java,comp.lang.java.programmer,comp.lang.java.help References: <3A63FC90.3C832EFA@chipcity.com.au> Subject: Re: Help! String as Integer Lines: 52 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Organization: Ye 'Ol Disorganized NNTPCache groupie Message-ID: <979631863.560899@red.hot.net.au> Cache-Post-Path: red.hot.net.au!unknown@host-216-252-147-57.interpacket.net X-Cache: nntpcache 2.3.2 (see http://www.nntpcache.org/) Date: Tue, 16 Jan 2001 18:57:07 +1100 NNTP-Posting-Host: 203.58.126.2 X-Complaints-To: abuse@telstra.net X-Trace: nsw.nnrp.telstra.net 979631761 203.58.126.2 (Tue, 16 Jan 2001 18:56:01 EST) NNTP-Posting-Date: Tue, 16 Jan 2001 18:56:01 EST