Java: Identifiers and Data Types

1. Identifiers

🎯 Good identifier choice is critical! It affects clarity, maintainability, and teamwork!

Rules for Java Identifiers:

Best Practices:


2. Primitive Data Types

Java has 8 primitive types, divided into 4 categories:

Category Types
Integer numbers byteshortintlong
Floating-point floatdouble
Textual char (single character)
Logical (Boolean) boolean (true or false)
Type Category Example Value Notes
byte Integer 100 8 bits, tiny integers
short Integer 20000 16 bits
int Integer 1_000_000 32 bits, common for numbers
long Integer 9_000_000_000L 64 bits, big numbers
float Floating Point 3.14f 32 bits, needs 'f' suffix
double Floating Point 3.1415926535 64 bits, very precise
char Textual (Character) 'A' single Unicode character
boolean Logical true / false logical decisions