I'm trying to add and put into the list is not just a number, so when you answer with an example, if you could use an object, for example, my used car or fruit or something else I looked every time, and all the examples that I see just add numbers to the list.
Im trying to convert some java code to scala java im code having conversion problems -
ArrayList usedCarList = new ArrayList();
UsedCars usedCar = new UsedCars();
usedCarList.add(usedCar);
Now I looked through a few examples, but they don't seem to work when I start trying to use an object, i.e.
var b = List[Int]();
b ::= 1;
b ::= 2;
b ::= 3;
I have tried several things that are 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, it is always empty
source
share