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:
- import java.io.*;
- class Main {
- public static void main (String[] args) {
- // String
- System.out.println("cool");
- // Integer
- System.out.println(1);
- // float takes up to 7 decimal positions
- System.out.println(3.1421242323243554545F);
- // double takes up to 15 decimal positions
- System.out.println(2.4143245423242342321);
- // long
- System.out.println(12345432123454321L);
- // boolean
- System.out.println(true);
- }
- }
Output:
cool
1
3.1421242
2.414324542324234
12345432123454321
true
Here is the Video: