|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
List Help
I'm extremely new to Java, so having some syntax issues. I'm trying to learn some data structures, and getting an error. Not sure why....
Code:
import java.util.List;
public class MyList {
public static void main(String[] args) {
List<String> l = new List<String>();
l.add("HELLO WORLD");
}
}
On the first line in main() I get this error: Cannot instantiate the type List<String> Anybody know what this means? Any help would be greatly appreciated... |
|
#2
|
||||
|
||||
|
List is an interface. You can't instantiate interfaces. In order to get an instance you must use an implementing class such as LinkedList or ArrayList.
Java Collections Tutorial
__________________
The day I get my hands on the cookbook it's all over. -nicky |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > List Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|