aspose file tools
The moose likes Java in General and the fly likes Allocates number within of array. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Allocates number within of array." Watch "Allocates number within of array." New topic
Author

Allocates number within of array.

Gustavo Siqueira
Ranch Hand

Joined: Jun 15, 2011
Posts: 94

Hello the all!
I want allocates number within of one array, see the program:



See the result:

Class1:
1
1
1
1
1
1

Or is, this allocating in all memory of array.

How to solved the problem ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You're printing the first element (class1[0]) each time.

Also, your loop condition should be while(i < class1.length); so < and not <=. Arrays in Java start at 0 and go to the length - 1 inclusive, or the length exclusive.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Allocates number within of array.
 
Similar Threads
Array problem
Wanted some help about arrays
and yet another recursive problem
something more about arrays
Accessing component from main class.... Help!