Java Variable Widening Example

Java Programming Java8Object Oriented ProgrammingJava Technologies

Widening refers to passing a lower size data type like int to a higher size data type like long. No casting is required in such a case.

public class MyFirstJavaProgram {
   public static void main(String []args) {
      int a = 300;
      long b = a;
      System.out.println(b);
   }
}
raja
Published on 22-Jan-2018 10:25:06
Advertisements