Article View: aus.computers.java
Article #324Re: Help! String as Integer
From: Jon Skeet
Date: Mon, 04 Jun 2001 20:21
Date: Mon, 04 Jun 2001 20:21
31 lines
2006 bytes
2006 bytes
kelb <bkkelly@qwest.net> wrote: > 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(); You seem to be presenting them as solutions to different problems, when actually they both solve *exactly* the same thing. The second method, however, creates an Integer object unnecessarily. I prefer String.valueOf (xx); myself. -- Jon Skeet - skeet@pobox.com http://www.pobox.com/~skeet If replying to the group, please don't mail me at the same time
Technical Details
Message-ID:
<MPG.1585fe15fb18770198a6bf@mrmog.peramon.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!npeer.kpnqwest.net!lnewspeer00.lnd.ops.eu.uu.net!lnewsifeed01.lnd.ops.eu.uu.net!lnewspost00.lnd.ops.eu.uu.net!emea.uu.net!not-for-mailReferences:
<3A63FC90.3C832EFA@chipcity.com.au> <3b16b1bd_3@news.bizonline.net> <NEYR6.31881$hV3.53039@newsfeeds.bigpond.com> <3b1bea8c.0@news>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,7de64e08ee658586 X-Google-Attributes: gid10d6db,public X-Google-Thread: 113ae9,7de64e08ee658586 X-Google-Attributes: gid113ae9,public X-Google-Thread: 10a146,5f124143cc4771e2 X-Google-Attributes: gid10a146,public X-Google-ArrivalTime: 2001-06-04 13:21:19 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!npeer.kpnqwest.net!lnewspeer00.lnd.ops.eu.uu.net!lnewsifeed01.lnd.ops.eu.uu.net!lnewspost00.lnd.ops.eu.uu.net!emea.uu.net!not-for-mail From: Jon Skeet <skeet@pobox.com> Newsgroups: aus.computers.java,comp.lang.java.programmer,comp.lang.java.help Subject: Re: Help! String as Integer Date: Mon, 4 Jun 2001 21:21:14 +0100 Message-ID: <MPG.1585fe15fb18770198a6bf@mrmog.peramon.com> References: <3A63FC90.3C832EFA@chipcity.com.au> <3b16b1bd_3@news.bizonline.net> <NEYR6.31881$hV3.53039@newsfeeds.bigpond.com> <3b1bea8c.0@news> Organization: Peramon Technology Ltd. X-Newsreader: MicroPlanet Gravity v2.30 Lines: 31 NNTP-Posting-Host: fw.peramon.com X-Trace: 991686078 reading.news.pipex.net 15022 193.132.195.125 X-Complaints-To: abuse@uk.uu.net