1

After thinking about ways to minimize my app size I wondered..

public int;
public boolean;

does one take up more memory than the other?

if instead they are:

public int = 0;
public boolean = false;

any difference there?

What about using an integer instead of a boolean( 1 & 2 ). Does that somehow take up less memory / space?

droidShot
  • 137
  • 2
  • 12

2 Answers2

1

It depends on the virtual machine. But there is no point in using an int rather than a boolean, at worst, they would take up the same amount of memory; at best it's just more efficient to use the boolean.

0

As far as I know the size of bool is virtual machine dependent. And bool is a primitive type so you cant set the value to null.

What about using an integer as a boolean( 1 & 2 ). Does that somehow take up less memory / space?

That does not make sense to use int where you want bool. The size or memory which both will take will depend on the system configuration which you have. But it would be better to use bool where you want bool.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331