aspose file tools*
The moose likes Beginning Java and the fly likes Reinitialize array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reinitialize array" Watch "Reinitialize array" New topic
Author

Reinitialize array

sudheesh_t
Greenhorn

Joined: Jul 21, 2003
Posts: 1
Can we reinitialize the array in java?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Well, you could use the overloaded static java.util.Arrays.fill() methods to set all the elements to null or 0 or false or whatever.
import java.util.Arrays;
...
int[] data = { 1,2,3,4,5 };
Arrays.fill(data, 0);


[Jess in Action][AskingGoodQuestions]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
(Lest one should slip away...)
sudheesh_t,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What exactly do you mean by "reinitialize the array"?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
 
subject: Reinitialize array
 
Similar Threads
initializing an Array of Objects
Delete an object
Anonymous Array
array declaration.
problem with ArrayList