Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Goal: Inserting an object in an ArrayList at a specified location. Problem : use

ID: 3879994 • Letter: G

Question

Goal: Inserting an object in an ArrayList at a specified location.

Problem : userList is an ArrayList of User objects that has already been declared and stores data for the following three users -- Jane, Jack and Sam.   Create a User object, u , with a name of "Paul", password of "apple", and loginCount of 5 and add this object to the userList between Jane and Jack.

The following field and methods are from a UML diagram for the User class.
- name: String
- password :String
- loginCount: int
+ User( ):
+ setName ( nm:String): void
+ setPassword( pw:String): void
+ setLoginCount( count: int): void

Explanation / Answer

The answer to the question is given below. Please do rate it it helped. thank you.

User u = new User();
u.setName("Paul");
u.setPassword("apple");
u.setLoginCount(5);
userList.add(1, u); //add the user u at index 1, i.e. between Jane and Jack

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote