🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #316

Re: Help! String as Integer

#316
From: Carl Schodde
Date: Fri, 01 Jun 2001 01:11
27 lines
2151 bytes
"Chris Smith" <cdsmith@twu.net> wrote in message
news:9f6i6i$h5d$0@dosa.alt.net...
> > Luke Vanderfluit <luke@chipcity.com.au> wrote ...
> > > I need to interpret a line of text as an integer.
> > >
>
> Using what conversion?
>
> > > 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
>
> As well it should, since neither "foo" nor "bar" are valid integer values.
> What integer value do you want to get back?  For one possible integer
value,
> you could use "foo".hashCode(), but that may not be what you want.

You could also use Integer.parseInt("foo");


> What *do* you want?
Technical Details
Message-ID: <ZTBR6.104$QW4.3681@ozemail.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!news1.optus.net.au!optus!news.mel.connect.com.au!news.netspace.net.au!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail
References: <3A63FC90.3C832EFA@chipcity.com.au> <3b16b1bd_3@news.bizonline.net> <9f6i6i$h5d$0@dosa.alt.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10a146,5f124143cc4771e2
X-Google-Attributes: gid10a146,public
X-Google-Thread: 113ae9,7de64e08ee658586
X-Google-Attributes: gid113ae9,public
X-Google-Thread: 10d6db,7de64e08ee658586
X-Google-Attributes: gid10d6db,public
X-Google-ArrivalTime: 2001-05-31 18:06:02 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!news1.optus.net.au!optus!news.mel.connect.com.au!news.netspace.net.au!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail
From: "Carl Schodde" <schodde@ozemail.com.au>
Newsgroups: aus.computers.java,comp.lang.java.programmer,comp.lang.java.help
References: <3A63FC90.3C832EFA@chipcity.com.au> <3b16b1bd_3@news.bizonline.net> <9f6i6i$h5d$0@dosa.alt.net>
Subject: Re: Help! String as Integer
Lines: 30
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Message-ID: <ZTBR6.104$QW4.3681@ozemail.com.au>
NNTP-Posting-Host: slbri54p57.ozemail.com.au
X-Trace: ozemail.com.au 991357561 203.108.72.121 (Fri, 01 Jun 2001 11:06:01 EST)
NNTP-Posting-Date: Fri, 01 Jun 2001 11:06:01 EST
Organization: OzEmail Ltd, Australia
Distribution: world
Date: Fri, 1 Jun 2001 11:11:12 +1000