'1e5 which is equivalent to 10^5 . Is this value represents double or int in java. Can You please elaborate the concept [closed]

This Code is giving error that lossy conversion from double to int.

int[] ans=new int[1e5+1];



Solution 1:[1]

The concept is simple: 1E5 is a 'double' floating-point number in Java because the Java language specification says it is.

Meanwhile, an array size must be integral, and the compiler is telling you that. If you really want to use a floating-point number there, you need to cast to int. However, it's easier to just write 100000.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 passer-by