Avatar ·

How to create a new List in Java: ArrayList, LinkedList and other options

Hello everyone! I just started learning Java and I can't figure out how to create lists. There seems to be a List interface, but directly using new List() doesn't work — the compiler complains. I've read that I need to use ArrayList or LinkedList, but I don't understand the difference and when to use which.\n\nHere's what I tried:\n\n```java\nimport java.util.List;\n\npublic class Main {\n public static void main(String[] args) {\n // This doesn't work — compilation error\n List myList = new List();\n \n // This seems to work, but it's strange\n List list2 = new ArrayList<>();\n list2.add("Hello");\n list2.add("World");\n System.out.println(list2);\n }\n}\n```\n\nI have several questions:\n1. Why can't I just write new List()? After