Hi,
I'm trying to do something pretty straightforward (I think) but it's not working for me for some reason. Basically trying to create an object with an ArrayList as a attribute but i keep getting numerous errors saying '<identifier> expected', '; expected'.

My code is as follows:

import java.util.ArrayList;

public class testALObject

{


public String surname;
public ArrayList<String>() firstname;

public testALObject()
	{

	}

}

I haven't even put anything in the constructor as can't get past the first line. I've coded plenty of Objects before but never used an ArrayList so can't figure out where I'm going wrong?

Any help would be greatly appreciated!

the error is here:

public ArrayList<String>() firstname;

replace it with:

public ArrayList<String> firstname;

Thanks, I actually spent about 40 minutes trying to fix this before posting the above then solved it 5 minutes later. Tried to delete the post and then couldn't. Thanks for helping!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.