How to add one item to the first free space of an array? Dr Java?
Currently, I have the code:
public void addNum(double number)
{
for(int i = 0; i < items.length; i++){
items[i] = number;
}
System.out.println( number + " added to array.");
}
This adds the added number to every zero spot in the array. How could I make it only add the the first zero spot it comes across?
Thanks
|