Article View: aus.computers.java
Article #323Re: Help! String as Integer
From: kelb
Date: Mon, 04 Jun 2001 20:08
Date: Mon, 04 Jun 2001 20:08
74 lines
2942 bytes
2942 bytes
try this:
String bb;
int xx = 2;
bb = String.valueOf(xx);
this will give the value of the xx var as a String object...
--this valueOf(int x) method is static so you don't need to instantiate a
String object to utilize it...
or, if you're trying to convert an int to a String, just use this:
Integer xx = new Integer(2);
xx.toString();
best.
kelbarnes.
"Paul Murray" <pmurray@nospam.bigpond.com> wrote in message
news:NEYR6.31881$hV3.53039@newsfeeds.bigpond.com...
> See java.text.ChoiceFormat .
>
> --
> --------------------------------------------------------------
> Sometimes he answers "Yes", sometimes "No", sometimes "Wait", and
sometimes
> he gives you something different.
> You get the same set of responses praying to a rock.
> http://www.users.bigpond.com/pmurray
> ICQ: 26066755
>
> "rastgoo" <rastgoo@thefreeinternet.co.uk.NOSPAM> wrote in message
> news:3b16b1bd_3@news.bizonline.net...
> >
> > 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:
<3b1bea8c.0@news>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!upp1.onvoy!onvoy.com!news-out.visi.com!hermes.visi.com!pulsar.dimensional.com!dimensional.com!coop.net!news.coop.net!news!207.174.157.2References:
<3A63FC90.3C832EFA@chipcity.com.au> <3b16b1bd_3@news.bizonline.net> <NEYR6.31881$hV3.53039@newsfeeds.bigpond.com>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: 10d6db,7de64e08ee658586 X-Google-Attributes: gid10d6db,public X-Google-Thread: 113ae9,7de64e08ee658586 X-Google-Attributes: gid113ae9,public X-Google-ArrivalTime: 2001-06-04 13:08:24 PST From: "kelb" <bkkelly@qwest.net> Newsgroups: aus.computers.java,comp.lang.java.programmer,comp.lang.java.help References: <3A63FC90.3C832EFA@chipcity.com.au> <3b16b1bd_3@news.bizonline.net> <NEYR6.31881$hV3.53039@newsfeeds.bigpond.com> Subject: Re: Help! String as Integer Date: Mon, 4 Jun 2001 14:08:15 -0600 Lines: 76 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <3b1bea8c.0@news> NNTP-Posting-Host: 206.168.216.12 X-Trace: 4 Jun 2001 14:08:22 -0600, 206.168.216.12 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!upp1.onvoy!onvoy.com!news-out.visi.com!hermes.visi.com!pulsar.dimensional.com!dimensional.com!coop.net!news.coop.net!news!207.174.157.2