• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with this error  RSS feed

 
Emmanuel Faneye
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,
I am new to Java but having this problem I cannot seem to ge around, please elighten me on this error and how to get correct it.

I have a Name Class with the following fields String firstName, lastNme; getter and setter methods for firstName and lastName

public class Name {
private String firstName;
private String lastName;

public String getFirstName() {return firstName;}
public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {return lastName;}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

and also a Person Class with field Name name with getter and setter methods Name

public class Person {
private Name name;

public Name getName() {return name;}
public void setName(Name name) {
this.name = name;
}

}

In main, I created Name object and initialized it
Name name = new Name();
name.setFirstName("Name1");
name.setLastName("Name2");

created Person object and initialized with name object
Person person = new Person();
// person.setName(name);
List<Person> persons = new ArrayList<Person>(); Error on this line ** Generics are not supported in -source1.4 (use sorce 5 or higher to enable generics)
persons.add(person);
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generics are introduced from JDK 1.5

It seems you are using JDK 1.4.

Also use code tag when posting code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!