Long vs int | Selenium Forum
V
vinaysa86 Posted on 22/08/2019

int a = 999999999;
long b=999999999;

This gives no error.

But when I use long b=9999999999;

It gives error. Why ?

In video, it was told that long is greater than int.


A
Ashish Thakur Replied on 23/08/2019

By default the value is picked up as int even for a long type variable.

 

Please go through the below code for better understanding of int and long

	public static void main(String[] args) {
		int a;
		long b;
		a = 2147483647;
		b = Long.valueOf(a) * Long.valueOf(a);
		
		System.out.println(a);
		System.out.println(b);
	}


V
vinaysa86 Replied on 24/08/2019

Thanks.

Got my answer.