What is the range of int data type?
class DataType5
{
public static void main(String[] args)
{
int i=2147483648;
System.out.println(i);
}
}
/*
Output:- CE[integer number too large]
Explanation:- "int" data type value has a range between -2147483648 to 2147483647.
if we are trying to assign a value greater than its range then will rise an
error(integer number too large) but if are assigning long data type value then
it will rise an error(possible loss of precision).
*/
{
public static void main(String[] args)
{
int i=2147483648;
System.out.println(i);
}
}
/*
Output:- CE[integer number too large]
Explanation:- "int" data type value has a range between -2147483648 to 2147483647.
if we are trying to assign a value greater than its range then will rise an
error(integer number too large) but if are assigning long data type value then
it will rise an error(possible loss of precision).
*/
0 comments: