Java arrays

Is there a way to clear all values in an array of integers without having to create a loop and going through each one?


is one way, read through this this for more info>><<

its still a loop as each allocation of memory is returned to null.... same as what you would do in a 'for' loop.

I'd do as deejeeta suggested and change the data structure to an ArrayList to make use of clear(). If you HAVE to stick to an array, you can also make it an array of Integer instead of int and do: Arrays.fill(yourArray, null); //ew


alright, thanks for the help guys. i ended up just using a for loop since i needed to get it done for a project but your suggestions are helpful for future use.