Henry Henry - 1 year ago 59
Java Question

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);

Answer Source

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