Widening Primitive Conversion in Java

Following is an example showing widening primitive conversion −

Example

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: 2026-03-11T22:50:50+05:30

305 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements