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);

Recommended Answers

All 5 Replies

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."

@cOrRuPtG3n3t!x please use links to the current Java6/Java7 API's, because in most of them were important changes in nested on inherits methods however +1 for simple and clear suggestion

@cOrRuPtG3n3t!x please use links to the current Java6/Java7 API's, because in most of them were important changes in nested on inherits methods however +1 for simple and clear suggestion

Yes sorry i never even saw the version but i do understand current documentation is always a the better choice, wont make that mistake again :)...

@OP here is the newer java 7 docs:http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

[EDIT]
lol yup Ezzaral, thats actually exactly how it happened-was my first google result :P

The Java 1.4.2 docs do seem to come up near the top of search results fairly often, so it's an easy mistake to make if you don't glance at the version.

ok then thanks for your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.