Problem statement:
Can you let me know the output of the following code?
Can you let me know the output of the following code?
- public class ExecutionTwo {
- public static void main(String[] args) {
- // primitive data type
- double d1 = 0.8;
- double d2 = 0.8;
- System.out.println(d1 == d2);
- double d3 = 0.8d;
- double d4 = 0.8d;
- System.out.println(d3 == d4);
- double d5 = 0.8D;
- double d6 = 0.8D;
- System.out.println(d5 == d6);
- // Wrapper class
- Double d7 = 0.8;
- Double d8 = 0.8;
- System.out.println(d7.equals(d8));
- Double d9 = 0.8d;
- Double d10 = 0.8d;
- System.out.println(d9.equals(d10));
- Double d11 = 0.8D;
- Double d12 = 0.8D;
- System.out.println(d11.equals(d12));
- }
- }
Output:
true
true
true
true
true
true
No comments:
Post a Comment