Long
long is singed 64 bit type of and is useful for those hen occasions where an int type is not large enough to hold the desired value . the range or long is quite large. This makes is useful when big whole numbers are needed . for example.
here is a program that computer the numbers of miles that light will be travel in specified numbers of the days.
class Light{
public static void main(String[]args)
{
int lightSpeed;
long days;
long seconds;
long distance;
lightSpeed=186000;
days=1000;
seconds=days*24*60*60;
distance=lightSpeed*seconds;
System.out.println("IN"+days);
System.out.println("days light will be travel about ");
System.out.println(distance+"miles");
}
}
long is singed 64 bit type of and is useful for those hen occasions where an int type is not large enough to hold the desired value . the range or long is quite large. This makes is useful when big whole numbers are needed . for example.
here is a program that computer the numbers of miles that light will be travel in specified numbers of the days.
class Light{
public static void main(String[]args)
{
int lightSpeed;
long days;
long seconds;
long distance;
lightSpeed=186000;
days=1000;
seconds=days*24*60*60;
distance=lightSpeed*seconds;
System.out.println("IN"+days);
System.out.println("days light will be travel about ");
System.out.println(distance+"miles");
}
}
0 comments:
Post a Comment