private void buildPersonOptions(){
        List<Person> personList= null;
    }

I put this code in and it asked to import the class Person.
as far as I know there is a null list(personList) of the type List.
so
why is the List have this thing?
<Person> is what?
-Steve

Recommended Answers

All 2 Replies

There is a null personList of type List, but you declare that the null personList List will have ONLY elements of type Person.
The personList maybe null, it is type List but you put "things" in the List. And you declare that when you are going to put things in the List the elements will be of type Person.

List<Person> personList= null;

Then somewhere else in the code:

personList = new ArrayList<Person>();
personList.add(new Person());

//the following is wrong:
personList.add(new String("Aaaaa"));
//you can put only Person objects in the List

But this would be correct:

List list = new ArrayList();

personList.add(new Person());
personList.add(new String("Aaaaa"));

But not recommended

Awesome.
thanks
I have another thread out there to. {primary key,and,Option[]}
could you look it over and see if it is answerable?
Thanks again
-Steve

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.