• Post Reply Bookmark Topic Watch Topic
  • New Topic

write a method to remove emp object based on last name from the arraylist?  RSS feed

 
seshagiri bollineni
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q3. Assume that an employee class is defined as given below.



Public class Employee{

String fristName;

String lastName;

Double salary;

}

Use the 'generics' feature of Array list (that is the array list can contain only objects of type Employee). Please write a removeEmployee method which has the signature of taking the generic ArrayList and the lastName attribute. The removeEmployee method needs to be remove all the employees from the array list matching the last name.

 
Rob Spoor
Sheriff
Posts: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far? Have you looked at the ArrayList API?
 
Campbell Ritchie
Marshal
Posts: 56223
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

As you know we expect users to do their assignments, so we cannot tell you an answer. We shall however be only to happy to help if you show what you have achieved so far.
That is actually quite easy: 10 lines including { and } lines.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!