permaculture playing cards
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


Onslow McCann

Joined: Aug 29, 2007
Posts: 18

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.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();

I've tried to initialize the ArrayList in my main method but am getting the following error '(' or '{' expected
ArrayList<MakePlayer> playerLijst = new ArrayList<MakePlayer>();

1 error

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

Joined: Jul 08, 2003
Posts: 24199


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 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

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

Joined: Aug 29, 2007
Posts: 18
Ah, JDK as opposed to JRE.
Got it now.
I agree. Here's the link:
subject: ArrayList
jQuery in Action, 3rd edition