How to Demonstrat Different Data Types in Java


In this example we will show different data types in Java.

Source Code

package com.beginner.examples;


public class DataTypeExample {
  
  
    public static void main(String args[]){
        int i = 3;          // int
        float f = 0.57f;    // float
        char c = 'd';       // char
        boolean b = true;   // boolean
        String s = "test";  // String
        System.out.println(i);
        System.out.println(f);
        System.out.println(c);
        System.out.println(b);
        System.out.println(s);
    }
}

Output:

3
0.57
d
true
test
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments