How to Widen Casting in Java


In this example we will show the method to widen Casting in Java.

Source Code

package com.beginner.examples;

public class WidenCasting {
  public static void main(String[] args) {
    int i = 1;
    double d = i; // widen Casting

    System.out.println(i);
    System.out.println(d);
  }
}

Output:

1
1.0
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments