Help me solve this code problem? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Help me solve this code problem?

Suggest what wrong did i did? https://code.sololearn.com/cifL927BZ1LA/?ref=app

30th Aug 2019, 7:21 AM
Piyush Srivastava
Piyush Srivastava - avatar
4 Answers
+ 5
First you have to define the type you wanna insert to the arraylist like this: ArrayList <Integer> list = new ArrayList <Integer>(Here you can choose the size, but you can leave it empty); Here is the fixed code and look at the comment I added: https://code.sololearn.com/cKfte7vulSKk/?ref=app
30th Aug 2019, 7:26 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 2
30th Aug 2019, 8:00 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 2
There is nothing wrong with your code if you want to remove any number that is less than 3 or greater than 6 and || Will work for that, but if you are using && operator then there is no need to use iterator because your condition is going to be false always and hence nothing will be removed from the list
30th Aug 2019, 6:53 PM
Rajan Pandey
Rajan Pandey - avatar
+ 1
Thanks Eliya
30th Aug 2019, 7:53 AM
Piyush Srivastava
Piyush Srivastava - avatar