🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #300

Help! String as Integer

#300
From: Luke Vanderfluit
Date: Tue, 16 Jan 2001 07:47
26 lines
1770 bytes
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: <3A63FC90.3C832EFA@chipcity.com.au>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!newsfeed.berkeley.edu!ucberkeley!logbridge.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!uunet!dca.uu.net!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113ae9,7de64e08ee658586,start
X-Google-Attributes: gid113ae9,public
X-Google-Thread: 10a146,7de64e08ee658586,start
X-Google-Attributes: gid10a146,public
X-Google-Thread: 10d6db,7de64e08ee658586,start
X-Google-Attributes: gid10d6db,public
X-Google-ArrivalTime: 2001-01-15 23:49:48 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!newsfeed.berkeley.edu!ucberkeley!logbridge.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!uunet!dca.uu.net!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail
Message-ID: <3A63FC90.3C832EFA@chipcity.com.au>
From: Luke Vanderfluit <luke@chipcity.com.au>
X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i586)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: aus.computers.java,comp.lang.java.programmer,comp.lang.java.help
Subject: Help! String as Integer 
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 29
NNTP-Posting-Host: 1cust3.tnt1.willunga.au.da.uu.net
X-Trace: ozemail.com.au 979631306 210.84.166.131 (Tue, 16 Jan 2001 18:48:26 EST)
NNTP-Posting-Date: Tue, 16 Jan 2001 18:48:26 EST
Organization: OzEmail Ltd, Australia
Distribution: world
Date: Tue, 16 Jan 2001 18:17:29 +1030