This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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.

 
Sheriff
Posts: 21288
87
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?
 
Marshal
Posts: 58340
178
  • 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!