Array list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Array list

How to write code for Negative numbers using arraylist in java

25th Jun 2019, 10:16 AM
Ramchandra Reddy
4 Answers
+ 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?
25th Jun 2019, 4:11 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
do changes from Denise and System.out.println(negativeNumbers(-10,0)); ... for(int i = firstValue; i <= endValue; i++){ //<=
25th Jun 2019, 5:11 PM
zemiak
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);
25th Jun 2019, 11:49 AM
zemiak
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
25th Jun 2019, 12:06 PM
Ramchandra Reddy