write a program to print and search an element from a list by using function
Answers
Answered by
0
Answer:
List fruits = Arrays.asList("apple", "orange", "grape",
"banana", "melon");
System.out.println("t2: " + fruits);
String trg = "grape";
System.out.println("index of \"" + trg + "\": " + fruits.indexOf(trg));
trg = "pear";
System.out.println("index of \"" + trg + "\": " + fruits.indexOf(trg));
Explanation:
Similar questions