This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Reinitialize 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 » Beginning Java
Reply 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: 24057
    
  13

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Reinitialize array
 
Similar Threads
problem with ArrayList
Delete an object
array declaration.
initializing an Array of Objects
Anonymous Array