Java Data Types Example

βœ… Java Data Types β€” Examples

Here’s a complete practical example of all main Java data types in action: primitive and non-primitive.


πŸ“Œ Example Program


 


πŸ“Œ Output

Byte Age: 25
Short Year: 2025
Int Population: 1400000
Long Distance: 12345678900
Float Price: 9.99
Double Salary: 50000.75
Boolean isJavaFun: true
Char Grade: A
String Name: Vipul
Sum of a + b: 30

πŸ”Ή Notes:

  1. Primitive Data Types: byte, short, int, long, float, double, boolean, char

  2. Non-Primitive Data Type: String (used for text)

  3. You can combine variables in expressions and print them.

  4. final keyword can make any variable constant (unchangeable).

You may also like...