• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

How to pass a constructor using arraylist

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
}


 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think want you want is..



Also, please put your code between the code tags ...
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To add a DvdInfo object to an array list, you create the object, and call "add()" on the list:



or on one line:

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic