Hi,
Im looking to find a piece of code which will take an array of ints and then subtract 1 away from each element that array to keep doing this for a certain amount of times. I've managed to make a method which takes away 1 from the array as shown below
public static void subtraction(int[] num){ System.out.println("contents of array after subtracting 1 from each element is "); for(int i = 0; i < num.length; i++){ System.out.println((num[i] - 1));
However I can only get it to subract once, so its obvious to me that I need some form of loop to cycle through and keep subtracting. However every effort Ive made the program will only ouput that first subtraction.


LinkBack URL
About LinkBacks
Reply With Quote