🎯 Good identifier choice is critical! It affects clarity, maintainability, and teamwork!
Rules for Java Identifiers:
class
, public
, void
, etc.).Best Practices:
Person
, OrderSystem
).userName
, calculateTotal()
).MAX_SIZE
).utilities.math
).Java has 8 primitive types, divided into 4 categories:
Category | Types |
---|---|
Integer numbers | byte , short , int , long |
Floating-point | float , double |
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 |