Java Program To Demonstrate Various Datatype

Java Program To Demonstrate Various Datatype

Write Java program to demonstrate use of various datatypes

// WAP to demonstrate various data types

import java.util.Scanner;
public class DataTypes
    public static void main(String []args) 
       boolean bool;
       byte by;
       char ch;
       short sh;
       int i;
       long l;
       float f;
       double d;

       Scanner sc = new Scanner(;
       System.out.println("Enter boolean value :-->"); 
       bool = sc.nextBoolean();

       System.out.println("Enter byte value :-->"); 
       by = sc.nextByte();

       System.out.println("Enter char value :-->"); 
       ch =;

       System.out.println("Enter short value :-->"); 
       sh = sc.nextShort();

       System.out.println("Enter int value :-->"); 
       i = sc.nextInt();

       System.out.println("Enter long value :-->"); 
       l = sc.nextLong();

       System.out.println("Enter float value :-->"); 
       f = sc.nextFloat();

       System.out.println("Enter double value :-->"); 
       d = sc.nextDouble();

       System.out.println("Scanned values are :\n");
       System.out.println("Boolean value is :-->"+bool);
       System.out.println("byte value is :-->"+by);
       System.out.println("char value is :-->"+ch);
       System.out.println("short value is :-->"+sh);
       System.out.println("int value is :-->"+i);
       System.out.println("long value is :-->"+l);
       System.out.println("float value is :-->"+f);
       System.out.println("double value is :-->"+d);