my dog learned polymorphism
The moose likes Beginning Java and the fly likes How to pass a constructor using arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to pass a constructor using arraylist" Watch "How to pass a constructor using arraylist" New topic

How to pass a constructor using arraylist

Ja King

Joined: May 15, 2009
Posts: 28
import java.util.*;
class ArrayLists
public static void main(String args[])
ArrayList<DvdInfo> dvdList = new ArrayList<DvdInfo>();
//i want to pass the string value("Caddy Shack/comedy/Murray, Bill")
//dvdList("Caddy Shack/comedy/Murray, Bill");
class DvdInfo
String title,genre,actors;
DvdInfo(String title,String genre,String actors)
this.title = title;
this.genre = genre;
this.actors = actors;
public String toString()
return title+ " " +genre+ " " +actors;

Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
I think want you want is..

Also, please put your code between the code tags ...

JDBCSupport - An easy to use, light-weight JDBC framework -
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193

To add a DvdInfo object to an array list, you create the object, and call "add()" on the list:

or on one line:

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: How to pass a constructor using arraylist
It's not a secret anymore!