🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: StrToInt function?

#15040
From: Steve Schafer (TeamB)
Date: Tue, 13 Jul 1999 00:00
29 lines
1382 bytes
On Tue, 13 Jul 1999 09:20:29 -0700, Dave Hatzenbuehler
<daveh@insynclh.com> wrote:

>I am looking for a way to convert a string to an integer value.  I have
>the following line of code:
>
>String cStr = 'abc';
>int nNum = Integer.valueOf( cStr ).intValue.
>
>I keep getting "intValue not found in java.lang.Integer."  I have import
>java.lang.Integer and I still get this error.

intValue() is a method, not a field, so you have to include the
trailing empty parentheses. That said, however, it's not clear to me
what you expect the integer value of the string "abc" to be.

Here's a complete program that shows the idea:

 public class Test {

   public static void main(String[] argv) {
     String cStr = "123";
     int nNum = Integer.valueOf(cStr).intValue();
     System.out.println(nNum);
     }

   }

-Steve
Technical Details
Message-ID: <37b775c2.306103649@90.0.0.40>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <378B674D.8818D1F6@insynclh.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,ecbec2f1a10fd049
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: StrToInt function?
Date: 1999/07/13
Message-ID: <37b775c2.306103649@90.0.0.40>
X-Deja-AN: 500586575
Content-Transfer-Encoding: 7bit
References: <378B674D.8818D1F6@insynclh.com>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language