Article View: borland.public.jbuilder.java.language
Article #19266Re: how do I instantiate an int?
From: vince farino
Date: Sat, 21 Feb 1998 00:00
Date: Sat, 21 Feb 1998 00:00
42 lines
1751 bytes
1751 bytes
FYI: There is a Stadard class called Integer that encapsulates the basic
type int. Check the java.lang package for help in using this class and its
methods.
Vince
Kurt Hall wrote in message <34ED5724.107CCFA5@clear.com>...
>'int' is a primitive type (not a class) and Integer is it's
>corresponding class.
>
>int i=100; // all that's needed
>
>If you'd like to treat it as a constant, its recommended to declare it
>to be static final.
>
>e.g.
>====
>
>static final int NUMFIELDS=100;
>...
>for( int i=0; i<NUMFIELDS; i++) {...}
>
>---
>
>
>-kurt
>
>
>
>Alex Humphreys wrote:
>>
>> I'm trying to create a simple int variable that I can use as an index in
>> a loop. How do I declare it? When i try the obvious (int my_int = new
>> int();) I get an error saying that "class required but int found." When
>> I try running the loop without declaring the index, it tells me that
>> my_int not found in class my_class.
>>
>> And when I doing the whole thing with Integers, I can't figure out how
>> to add anything(!)--I get errors saying that the method
>> +(java.lang.Integer, java.lang.Integer) not found in class my_class.
>>
>> What's going on here? How can I resolve this? Thanks!
Technical Details
Message-ID:
<6cn2tg$4r9@bgtnsc02.worldnet.att.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<34EC6D40.C8913D5F@sema4.com> <34ED5724.107CCFA5@clear.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,ea4f9ce85b8e382 X-Google-Attributes: gidf74b3,public From: "vince farino" <v.c.f@worldnet.att.net> Subject: Re: how do I instantiate an int? Date: 1998/02/21 Message-ID: <6cn2tg$4r9@bgtnsc02.worldnet.att.net> X-Deja-AN: 327295632 References: <34EC6D40.C8913D5F@sema4.com> <34ED5724.107CCFA5@clear.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Organization: AT&T WorldNet Services Newsgroups: borland.public.jbuilder.java.language