So I have this method that takes an (ArrayList, int n, int r), let's just say that the method is supposed to print something if given those args.
but for some reasons, if my main is like this:
public static void main(String[] args) {
ArrayList<Double> array = new ArrayList<Double>();
int r = 2;
int n = array.size();
array.add(4.0);
array.add(5.0);
array.add(7.0);
array.add(8.0);
array.add(10.0);
print(array, n, r);
}
it doesn't work, or at least it doesn't do what it's supposed to do.
BUT if my main method is like this:
public static void main(String[] args) {
ArrayList<Double> array = new ArrayList<Double>();
array.add(4.0);
array.add(5.0);
array.add(7.0);
array.add(8.0);
array.add(10.0);
int r = 2;
int n = array.size();
print(array, n, r);
}
it works perfectly fine.
Does the location of where I created those integers have any effect on my code? Any explanation on why this happens?
ps: I'm fairly new on programming, so if this is actually really simple... I apologize for not knowing.