wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList" Watch "ArrayList" New topic
Author

ArrayList

Onslow McCann
Greenhorn

Joined: Aug 29, 2007
Posts: 18
Hello,

I've made a working Darts score program but I'm trying to improve it.
I'm trying to use an ArrayList to hold the player objects but can't get the thing to work.


import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

public class DartsScore
{
public static void main (String[] args)
{
ArrayList<MakePlayer> playerLijst = new ArrayList<MakePlayer>();
StartFraem Chrisframe = new StartFraem();
Chrisframe.setSize(100,250);
Chrisframe.setVisible(true);
Chrisframe.setResizable(false);
Chrisframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Chrisframe.setLocation(400,100);
}
}

I've tried to initialize the ArrayList in my main method but am getting the following error

DartScore.java:16: '(' or '{' expected
ArrayList<MakePlayer> playerLijst = new ArrayList<MakePlayer>();
^

1 error


Any idea where I'm going wrong?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

Welcome to JavaRanch!

Generics (the thing with the angle brackets) were introduced in JDK 1.5 (Java 5). It looks like you're using an older compiler; i.e., from JDK 1.4 or earlier, which won't understand the notation at all. Head to java.sun.com and download a newer JDK; or if you're using an IDE, check that the compiler settings are set up to support JDK 1.5 or later.


[Jess in Action][AskingGoodQuestions]
Onslow McCann
Greenhorn

Joined: Aug 29, 2007
Posts: 18
Thanks Ernest for the speedie reply and the warm welcome!

You're right, even though I've got 1.6 version, the path variable was still pointing to 1.4 version. I've now changed the java variable in Path = %java%
to 1.6 version....

java = C:\Program Files\Java\jre1.6.0_02\bin

but it looks as if it's using 1.4 to compile. When I delete the whole 1.4 map it stops compiling all together! Got some more advice?
Onslow McCann
Greenhorn

Joined: Aug 29, 2007
Posts: 18
Ah, JDK as opposed to JRE.
Got it now.
Thanks!
 
GeeCON Prague 2014
 
subject: ArrayList