Just a quick question, how would you go about initializing a new ArrayList in a constructor which takes its values as parameters?

For example say I have a class which has an ArrayList of strings called bookings. I've already written a constructor which sets all fields to default values, so sets bookings to a new ArrayList of strings. However, the task I've been given is to write a second constructor which uses parameters to set the field values instead of setting them to defaults. This is fine for all my other fields, but how would I do this with the ArrayList?


ArrayList<String> lstData = new ArrayList<String>(




    ArrayList JAVA Array


    Frank 發表在 痞客邦 留言(0) 人氣()