I am trying to add and object to a list not just a number so when you reply with an example if you could use an object like my used car example or a fruit or something
I've been looking every where and all the examples i see are just adding numbers to a list.
Im trying to convert some java code into scala
the java code im having trouble converting is
ArrayList usedCarList = new ArrayList();
UsedCars usedCar = new UsedCars();
usedCarList.add(usedCar);
Now i've looked at a few examples but they dont seem to work once i start trying to use an object ie
var b = List[Int]();
b ::= 1;
b ::= 2;
b ::= 3;
I've tried a few things 1 is listed below.
var usedCarList = List();
def addCar (usedCarList: List[UsedCars]){
var usedCar = new UsedCars();
series of set operations on the usedCar
usedCar :: usedCarList;
println(usedCarList.length);
}
when i check the size of the list its always empty