For Beginners: This guide simplifies a complex topic. We'll focus on what you need NOW and clearly mark what you can come back to later.
In 90% of the code you'll write as a beginner, you only need two number types:
int age = 25;
int studentsInClass = 42;
int daysInWeek = 7;double price = 19.99;
double temperature = 36.5;
double piValue = 3.14159;That's it! This covers most situations you'll encounter while learning.
- Write a whole number like
42→ Java treats it asint - Write a decimal number like
3.14→ Java treats it asdouble
// ❌ This won't work - can't fit a decimal into an integer type
double price = 19.99;
int dollars = price; // COMPILE ERROR
// ✅ Fix #1: Keep it as double
double dollars = price;
// ✅ Fix #2: Convert to int (chops off decimal part)
int dollars = (int) price; // dollars will be 19Key insight: Java is strict about types. An int can only hold whole numbers, a double can hold decimals.
The following topics are in your course material but are NOT essential for beginners. You can safely skip them and come back when you encounter them in real code:
- When you'll need it: Memory optimization in Android apps or embedded systems
- Why skip now:
intworks fine for learning
long bigNumber = 9223372036854775807L; // Notice the 'L' at the end- When you'll need it: Working with timestamps, file sizes, or database IDs
- Why skip now: Regular
inthandles numbers up to about 2 billion - plenty for practice
float smallDecimal = 3.14f; // Notice the 'f' at the end- When you'll need it: GPU programming, game development, or when a library requires it
- Why skip now:
doubleis almost always the better choice
int hexColor = 0xFF5733; // Hexadecimal
int octalValue = 027; // Octal (note the leading zero!)
int binaryValue = 0b101010; // Binary- When you'll need it: Colors (Android/web), bit manipulation, system programming
- Why skip now: You'll recognize the pattern when you see it in real code
double scientificNum = 1.5e-4; // = 0.00015- When you'll need it: Scientific computing, very large or small numbers
- Why skip now: Not common in everyday programming
int million = 1_000_000; // Same as 1000000- When you'll need it: Large numbers in production code
- Why skip now: Nice feature, but not essential for learning
Don't worry - these aren't useless! Here's when they become relevant:
// Working with dates/times in milliseconds
long timestamp = 1707753600000L; // Needs 'L' because it exceeds int rangeYou'll see this in: backend APIs, database timestamps, date handling
// Android or web development
int backgroundColor = 0xFF5733; // Orange color in hexadecimalYou'll see this in: UI development, graphics programming
// Working with large files
long fileSize = 5368709120L; // 5GB in bytesYou'll see this in: file handling, cloud storage apps
// Only when memory is critical (rare for beginners)
byte smallNumber = 127; // Uses 1 byte instead of 4 bytes (int)You'll see this in: embedded systems, Android resource optimization, network protocols
int decimal = 27; // This is 27 (what you expect)
int octal = 027; // This is 23! (Octal notation)Rule: Never put a leading zero on a number unless you specifically mean to use octal notation (which you probably don't).
Try these simple examples to get comfortable:
// What type should each variable be?
___ numberOfStudents = 30;
___ averageGrade = 87.5;
___ piValue = 3.14159;
___ daysInYear = 365;Click to see answers
int numberOfStudents = 30;
double averageGrade = 87.5;
double piValue = 3.14159;
int daysInYear = 365;// Which lines will cause compile errors?
int count = 100; // Line 1
double price = 29.99; // Line 2
int total = price; // Line 3
double average = 85; // Line 4Click to see answer
Line 3 will cause an error: can't assign double to int without casting.
Line 4 is FINE: Java automatically converts int to double (widening conversion).
For 99% of your learning:
- Whole numbers →
int - Decimals →
double - That's it!
Remember:
- Java won't let you mix types without being explicit
intcan becomedoubleautomaticallydoubletointneeds a cast:(int) myDouble
When you see weird notation:
0x...= hexadecimal (colors, low-level code)0b...= binary (bit manipulation)- Leading
0= octal (almost never used intentionally) ...L= long (big numbers)...f= float (GPU/graphics work)
Pro tip: Don't try to memorize all the types. Learn int and double thoroughly. When you encounter others in real code, you'll understand why they exist.
Remember: This is complex stuff even for experienced developers! The course material covers many edge cases that you won't use for months (or years).
Focus on understanding int and double first. Everything else can wait.
Post your questions in the #java-bootcamp Slack channel - we're building this together! 🚀
This guide is part of the WCC Java Bootcamp
Licensed under MIT License - feel free to share and adapt!