• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reinitialize array

 
sudheesh_t
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we reinitialize the array in java?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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!
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean by "reinitialize the array"?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic