View Single Post
Old Mar 11th, 2008, 7:50 PM   #1
fireblaze118
Newbie
 
Join Date: Mar 2008
Posts: 3
Rep Power: 0 fireblaze118 is on a distinguished road
Help why doesnt it work

Im new to Java and i am creating simple programs to start out but i ran into a problem with this:
My compiler says "M:\Java\DataType.java:22: integer number too large: 4000000002
k = 4000000002 ; // k to 4,000,000,002
^
1 error"
I Use JCreator.
and the Code is :
class datatype
{
public static void main(string args[])
{
double SQUARE_ROOT_OF_TWO = 1.414214;
int i; // i as an integer
long j; // j as a long integer
long k; // k as a long integer
float n; // n floating point number
long Speed_of_light;
long Speed_of_Sound;
long e;
Speed_of_light = (3.00e8);
e = Speed_of_light;
Speed_of_Sound = (340.292);
i = 3; // initialize i to 3;
j = -2048111; // j to -2,048,111

// The problem is This Line
k = 4000000002 ; // k to 4,000,000,002
//The problem is this line i cant see whats wrong with it.

n = (float) 1.887; // n to 1.887
System.out.println( SQUARE_ROOT_OF_TWO);
System.out.println( "i = " + i);
System.out.println( "j = " + j);
System.out.println( "k = " + k);
System.out.println( "n = " + n);
System.out.println(e);
System.out.println(Speed_of_Sound);
}
} // end of class DataType
fireblaze118 is offline   Reply With Quote