Java Question Write a Static method that accepts a List<T> argument. It should r
ID: 3759776 • Letter: J
Question
Java QuestionWrite a Static method that accepts a List<T> argument. It should return the number in the list that are equal to the element that comes before it.use only iterators to inspect the list. Do not use for loops or the get() method Java Question
Write a Static method that accepts a List<T> argument. It should return the number in the list that are equal to the element that comes before it.use only iterators to inspect the list. Do not use for loops or the get() method Java Question
Write a Static method that accepts a List<T> argument. It should return the number in the list that are equal to the element that comes before it.use only iterators to inspect the list. Do not use for loops or the get() method
Explanation / Answer
package Fruits.Variety.Example;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class FruitList {
public static void main(String[] args) {
string a=null;
// create list
List<String> FruitList = new ArrayList<String>();
// add different values to list
FruitList.add("apple");
FruitList.add("mango");
FruitList.add("cheery");
FruitList.add("banana");
Iterator<String> FruitIterator = FruitList.iterator();
while (FruitIterator.hasNext()) {
{if(a==FruitIterator.hasNext())
{System.out.println(FruitIterator.next());
}
}
a= FruitIterator.next();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.