Article View: aus.computers.java
Article #203Re: Help! String as Integer
From: Dimka
Date: Thu, 14 Jun 2001 11:07
Date: Thu, 14 Jun 2001 11:07
43 lines
2683 bytes
2683 bytes
couldnt agree more String.valueOf() is the best to go but the best suggestion is that for people who ask such questions in the first place, I have 3 letters "API"!!! Regards, Dimka Jon Skeet <skeet@pobox.com> wrote in message news:MPG.1585fe15fb18770198a6bf@mrmog.peramon.com... > 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:
<3b289ada$1@news.iprimus.com.au>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.mel.connect.com.au!newshub1.rdc1.nsw.optushome.com.au!news1.optus.net.au!optus!news0.optus.net.au!news.iprimus.com.auReferences:
<3A63FC90.3C832EFA@chipcity.com.au> <3b16b1bd_3@news.bizonline.net> <NEYR6.31881$hV3.53039@newsfeeds.bigpond.com> <3b1bea8c.0@news> <MPG.1585fe15fb18770198a6bf@mrmog.peramon.com>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-14 04:06:25 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.mel.connect.com.au!newshub1.rdc1.nsw.optushome.com.au!news1.optus.net.au!optus!news0.optus.net.au!news.iprimus.com.au From: "Dimka" <dimmon@iprimus.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> <NEYR6.31881$hV3.53039@newsfeeds.bigpond.com> <3b1bea8c.0@news> <MPG.1585fe15fb18770198a6bf@mrmog.peramon.com> Subject: Re: Help! String as Integer Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Original-NNTP-Posting-Host: 203.134.130.7 Message-ID: <3b289ada$1@news.iprimus.com.au> X-Original-Trace: 14 Jun 2001 21:07:06 +1000, 203.134.130.7 Date: Thu, 14 Jun 2001 21:07:41 +1000 NNTP-Posting-Host: 203.134.64.67 X-Trace: news0.optus.net.au 992516784 203.134.64.67 (Thu, 14 Jun 2001 21:06:24 EST) NNTP-Posting-Date: Thu, 14 Jun 2001 21:06:24 EST Organization: CWO Customer - reports relating to abuse should be sent to abuse@cwo.net.au