Page 72 - CTS - CSA TP - Volume 2
P. 72
COMPUTER SOFTWARE APPLICATION - CITS
// longValue()
long longResult = intValue.longValue();
System.out.println(“longValue(): “ + longResult);
// floatValue()
float floatResult = intValue.floatValue();
System.out.println(“floatValue(): “ + floatResult);
// doubleValue()
double doubleResult = intValue.doubleValue();
System.out.println(“doubleValue(): “ + doubleResult);
}
}
Output :
4 Long
• Represents a 64-bit signed integer.
• Methods include: longValue(), floatValue(), doubleValue().
Task_Long: Here’s an example program demonstrating the use of methods inherited from the Number
class for the Long class:
public class LongMethodsExample {
public static void main(String[] args) {
// Example using Long class
Long longValue = 123456L;
// longValue()
long longResult = longValue.longValue();
System.out.println(“longValue(): “ + longResult);
// floatValue()
float floatResult = longValue.floatValue();
System.out.println(“floatValue(): “ + floatResult);
// doubleValue()
double doubleResult = longValue.doubleValue();
System.out.println(“doubleValue(): “ + doubleResult);
}
57
CITS : IT & ITES - Computer Software Application - Exercise 90