+ 1
Array list
How to write code for Negative numbers using arraylist in java
4 Respostas
+ 1
import java.util.ArrayList;
Line 11: numbers.add(i);
I am not sure what you mean with negative numbers.
E.g.
ArrayList<Integer> negative = negativeNumbers(1, 10);
Do you want to add -1, -2, ... -9?
+ 1
do changes from Denise and
System.out.println(negativeNumbers(-10,0));
...
for(int i = firstValue; i <= endValue; i++){ //<=
0
post example of result, your question is not clear
import java.util.List;
import java.util.ArrayList;
ArrayList<Integer> als = new ArrayList<>(List.of(1,2,3,4,5) );
als.add(6);
System.out.println(als);
0
https://code.sololearn.com/cz86zaICi91d/?ref=app
Please make this code work making required changes.
The result should be
If I pass firstValue and endValue it should show negative values b/w