using List in java with Generics

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elangobala
    New Member
    • Sep 2007
    • 30

    using List in java with Generics

    Hai,
    I m using ArrayList in my java like

    List<Car> cars = new ArrayList<Car>( );

    Car s an separate class which has the car names. I have to add the data in to the List like the above.But its showing error. how to use these kinds of Collection using Generics
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by elangobala
    Hai,
    I m using ArrayList in my java like

    List<Car> cars = new ArrayList<Car>( );

    Car s an separate class which has the car names. I have to add the data in to the List like the above.But its showing error. how to use these kinds of Collection using Generics
    It would be handy if you'd shown us the exact error message and the relevant
    snippet of source code.

    kind regards,

    Jos

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by elangobala
      Hai,
      I m using ArrayList in my java like

      List<Car> cars = new ArrayList<Car>( );

      Car s an separate class which has the car names. I have to add the data in to the List like the above.But its showing error. how to use these kinds of Collection using Generics
      Which version of Java you have?
      Generics supported by Java-1.5

      Kind regards,
      Dmjpro.

      Comment

      Working...