🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Converting a string number to integer

#17754
From: Vasudevan Srinivasan
Date: Thu, 08 Oct 1998 00:00
31 lines
1565 bytes
Hi
i had tried that one, but valueOf(...) returns Integer class not int type. so
i got a compilation error.
anyway now i have rewritten the code as:
int iv = (new Integer(text.getText()).intValue();
but i would like to know the scope of this Integer class - thru out the
existance of the program or only until the end of the function.
thanks

Max Polk wrote:

> > String v = new String();
> > JTextField text;
> > int iv;
> > ...
> > v = text.getText();
> > Integer integervalue = new Integer(v);
> > iv = integervalue.intValue();
> > ...
> >
> > is there any easy way to do this conversion bypassing declaration of
> > extra variables/objects ?
>
> Yes -- try:
>
>      int      I = Integer.valueOf (text.getText ());
>
> Typically the "valueOf" methods convert things to an object of that type.
> "valueOf" occurs coverting back to string as well, such as
> String.valueOf() which accepts boolean, char, char[], double, float, int,
> long, and so forth.
Technical Details
Message-ID: <361D16E6.CC7B2C81@netrisk.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <361CDD1E.D3894642@netrisk.com> <MPG.1086bb539839fd1d9896a4@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,698598ce65fb7690
X-Google-Attributes: gidf74b3,public
From: Vasudevan Srinivasan <vasudevan@netrisk.com>
Subject: Re: Converting a string number to integer
Date: 1998/10/08
Message-ID: <361D16E6.CC7B2C81@netrisk.com>
X-Deja-AN: 399103476
Content-Transfer-Encoding: 7bit
References: <361CDD1E.D3894642@netrisk.com> <MPG.1086bb539839fd1d9896a4@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Organization: NetRisk Inc.
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language