Widening Primitive Conversion in Java


Following is an example showing widening primitive conversion −

Example

 Live Demo

public class Demo {
   public static void main(String[] args) {
      System.out.print("H" + "E");
      System.out.print('L');
      System.out.print('L');
      System.out.print('O');
   }
}

Output

HELLO

A class named Demo contains the main function. Here, the ‘print’ function is used to print specific characters in double quotes and then in single quotes. When the process of widening primitive conversion happens, the presence of ‘+’ operator is a must. This ‘+’ operator expects integer on both the left hand and right hand sides.

Updated on: 14-Jul-2020

173 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements