Java Program to Convert Integer Values into Byte, Character, Float

This is a Java Program to Convert Integer Values into Byte, Character, Float.

Enter any integer as input. After that we convert the given integer into byte and char by type casting (Explicit casting) but we can directly convert int value to float value as java itself performs this type of type casting (Implicit casting).

Here is the source code of the Java Program to Convert Integer Values into Byte, Character, Float. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

  1. import java.util.Scanner;
  2. public class Integer_Conversion
  3. {
  4.    public static void main(String[] args) 
  5.     {
  6.         int a;
  7.         byte b;
  8.         char c;
  9.         float d;
  10.         Scanner s = new Scanner(;
  11.         System.out.print("Enter any integer:");
  12.         a = s.nextInt();
  13.         b = (byte) a;  
  14.         System.out.println("Conversion into byte:"+b);
  15.         c = (char) a;
  16.         System.out.println("Conversion into char:"+c);
  17.         d = a;
  18.         System.out.println("Conversion into float:"+d);
  19.     }
  20. }


$ javac
$ java  Integer_Conversion
Enter any integer:97
Conversion into byte:97
Conversion into char:a
Conversion into float:97.0

Sanfoundry Global Education & Learning Series – 1000 Java Programs.


Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.

If you find any mistake above, kindly email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.