It's not a secret anymore!
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

Reinitialize array


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

Joined: Jul 08, 2003
Posts: 24199

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

Joined: Dec 10, 2001
Posts: 7023
(Lest one should slip away...)
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

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:
subject: Reinitialize array
It's not a secret anymore!