Search code examples
javaarraylistintegeraddition

Type mismatch: cannot convert from boolean to int


I am have a little problem with small part of my code: it says

Type mismatch: cannot convert from boolean to int.

Can someone please help me out? My code is below:

ArrayList<Integer> tower = new ArrayList<Integer>();
int Kilo = tower.add(1);
int Jan tower.add(2);

Solution

  • From what I understand from the code you provide, you need to use tower.get(1) etc. and not tower.add(1) etc.