Friday 15 January 2010

java - Storing a collection of objects on an Arraylist -


I am trying to store a collection of objects in the list, employ but me I get an error at employ.addAll () , I tried to do employ.add () , but I still get the error.

  Import java.util.ArrayList; Public class employee {public string full name; Public float wages; Public identity id; ArrayList & LT; Employee & gt; Employment = new arreelist & lt; Employee & gt; (); Employee (string name, float wage, id id) {this.FullName = name; This.wage = wages; This.ID = ID; } Employee E = new employee ("Tony", 1245, 2222); Employ.addAll (E); // Here is the error where I get the error}  

employment () is an archive to add an element, employ.add () .

  import java.util.ArrayList; Public class employee {public string full name; Public float wages; Public identity id; Employee (string name, float wage, id id) {this.FullName = name; This.wage = wages; This.ID = ID; } Public static zero main (string [] args) {ArrayList & lt; Employee & gt; Employment = new arreelist & lt; Employee & gt; (); Staff E = new employee ("Tony", 1245, 2222); Employ.add (e); }}  

No comments:

Post a Comment