hi i am trying to create a dvd rental system, up till now i have entered the client's details into an array list and have created a loan for every client that rented a dvd. But now i need to edit a part of this loan, for eg i need to change the dvd title of this loan. can you please help me in trying to do so?( i need to ask the user to input the new dvd title to replace the old one.). The methodclass contains the setters and getters.
methodclass c = new methodclass(); System.out.println(""); System.out.println("Please enter the DVD title you want to rent."); String dvdtitle = sc.next(); c.setDVDTitle(dvdtitle); LoanList.add(c); System.out.println("Please enter your name."); String name = sc.next(); c.setName(name); LoanList.add(c); System.out.println("Please enter your surname."); String surname = sc.next(); c.setSurname(surname); LoanList.add(c);
Take a look at the java docs: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html , especially the set() method which will replace a value: "set(int index, Object element)
Replaces the element at the specified position in this list with the specified element."
DavidKroukamp
Practically a Master Poster
Team Colleague
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169