🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #18386

Re: Integer to string conversions

#18386
From: Richard Wilkman
Date: Mon, 06 Jul 1998 00:00
66 lines
2555 bytes
Alexander:

Anything that comes from Object has a toString() method that can be
implemented, and all the wrapper classes like Integer and Double have
this method.

so, you would just use Integer.toString().

However, I see in your code that you are already doing this so I'm
confused about your question.  Do you want:

a)  Integer to string (as your title indicates)
b)  primitive int to String?  (in which case you'd do
String.valueOf())

-Rich

Alexander Anguiano wrote:
> 
> I was working with a Integer object and I was trying to create a comma
> delimited string
> 
> efficiently. Is there another way to convert integers to strings?  (The
> Integer class only
> 
> allows me to set the value at construction time.)
> 
> Have ---
>  BitSet recordMap ....
> 
>     for(int i = 0; i < recordMap.size(); i++) {
>       if (recordMap.get(i)) {
>         Integer recordNumber = new Integer(i);
>         if (result.length() == 0)
>           result.append(recordNumber.toString());
>         else result.append(','+ recordNumber.toString());
>       } // if
>     } // for
> 
> Want something like this
> 
>     Integer recordNumber = new Integer();
>     for(int i = 0; i < recordMap.size(); i++) {
>       if (recordMap.get(i)) {
>         recordNumber.setValue(i); //<------------ something like this
>         if (result.length() == 0)
>           result.append(recordNumber.toString());
>         else result.append(','+ recordNumber.toString());
>       } // if
>     } // for

-- 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rich Wilkman
Senior Quality Assurance Engineer
Borland JBuilder Team

If you see something that looks like an opinion up there,
it's mine and mine alone.

Mail sent to me from the newsgroups won't bounce but will
be ignored.  If I have time, I'll respond, but you  have
a better chance if you confine your posts to the newsgroups
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID: <35A154E3.A7479D5B@inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6nqmqm$16c@bgtnsc03.worldnet.att.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,e6efa13a8396e245
X-Google-Attributes: gidf74b3,public
From: Richard Wilkman <rwilkman@inprise.com>
Subject: Re: Integer to string conversions
Date: 1998/07/06
Message-ID: <35A154E3.A7479D5B@inprise.com>
X-Deja-AN: 369035488
Content-Transfer-Encoding: 7bit
References: <6nqmqm$16c@bgtnsc03.worldnet.att.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language