Problem:
Write a program that implements an LinkedQueue in java.
Output:
[GB, DE, FR, ES]
[GB, DE, FR, DE, ES]
list.get(3): DE
list.indexOf("DE"): 1
list.indexOf("IE"): -1
list.subList(1, 5): [DE, FR, DE, ES]
[GB, FR, DE, ES]
[GB, DE, FR, DE, ES]
list.get(3): DE
list.indexOf("DE"): 1
list.indexOf("IE"): -1
list.subList(1, 5): [DE, FR, DE, ES]
[GB, FR, DE, ES]
Solution:
public class TestStringList { public static void main(String[] args) { List<String> list = new ArrayList<String>(); Collections.addAll(list, "GB", "DE", "FR", "ES"); System.out.println(list); list.add(3, "DE"); System.out.println(list); System.out.println("list.get(3): " + list.get(3)); System.out.println("list.indexOf(\"DE\"): " + list.indexOf("DE")); System.out.println("list.indexOf(\"IE\"): " + list.indexOf("IE")); System.out.println("list.subList(1, 5): " + list.subList(1, 5)); list.remove("DE"); System.out.println(list); } }
buy tiktok views Increase your exposure on social media! Check out our deals and buy Instagram Followers, Buy Youtube Subscribers, and more! Fast, cheap, and 24/7 Support.
ReplyDelete