Skip to main content

Data types

Java | Data Types: Java data types are strings, numbers and boolean values.

One by One:

Strings:
        The strings are nothing but collection of characters and also text is in between double quotes.
        
Numbers:
        The numbers are sub divided into int, float, double and long.
        Ex: 10 is int, 3.14F is float, it takes up to 7 decimal positions, 2.414343 is double, 
        it takes up to 15 decimal positions and 1234565432112345L is long

Boolean:
         There are two boolean values, those are true and false.

Here is the Code:

  1. import java.io.*;

  2. class Main {
  3. public static void main (String[] args) {
  4.      // String
  5.      System.out.println("cool");
  6.      // Integer 
  7. System.out.println(1);
  8. // float takes up to 7 decimal positions
  9. System.out.println(3.1421242323243554545F);
  10. // double takes up to 15 decimal positions
  11. System.out.println(2.4143245423242342321);
  12. // long 
  13. System.out.println(12345432123454321L);
  14. // boolean
  15. System.out.println(true);
  16. }
  17. }

Output:
cool
1
3.1421242
2.414324542324234
12345432123454321
true

Here is the Video: