Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Declaring variable help Java
New Posts  All Forums:Forum Nav:

Declaring variable help Java

post #1 of 3
Thread Starter 
The question is:
Quote:
Declare a variable named myList of type java.util.List<String>
And I haven't the foggiest about how to go about that.
post #2 of 3
http://download.oracle.com/javase/6/...util/List.html

Not initialized:
List<String> myList
post #3 of 3
List is an interface, which means that it defines a group or set of classes that are required to act as is defined by the "List" interface.

As Boatski said, the following is a legal declaration:
Code:
List<String> myList;
However, if you wish to instantiate or create an Object that is of type List<String>, which is read "A list of base type String", for reference, you need to create an object of one of the types that implement the List interface.

As in: AbstractList, ArrayList, LinkedList, Vector
In example:
Code:
List<String> myList = new ArrayList<String>();
Send me a PM if you need any more help with Java.
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Declaring variable help Java