🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: how do I instantiate an int?

#19256
From: Kurt Hall
Date: Fri, 20 Feb 1998 00:00
36 lines
1469 bytes
'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: <34ED5724.107CCFA5@clear.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34EC6D40.C8913D5F@sema4.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: Kurt Hall <khallNOSPAM@clear.com>
Subject: Re: how do I instantiate an int?
Date: 1998/02/20
Message-ID: <34ED5724.107CCFA5@clear.com>
X-Deja-AN: 326677247
Content-Transfer-Encoding: 7bit
References: <34EC6D40.C8913D5F@sema4.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: None
Newsgroups: borland.public.jbuilder.java.language