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
Updated on 15-Jun-2020 05:56:52

Advertisements