This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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
Author

How to pass a constructor using arraylist

Ja King
Greenhorn

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");
System.out.println(dvdList);
}
}
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
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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]
 
Don't get me started about those stupid light bulbs.
 
subject: How to pass a constructor using arraylist