Syntax error Java Variable Widening Example

Java Variable Widening Example



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);
   }
}
Updated on: 2020-06-15T05:56:52+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements