We fill the Insan class we created in the previous episode with variables. We compare a variable to a bucket: we decide what to put in the bucket (data type), who can access it (access modifier) and name it up front. We define String, int, double and boolean variables and assign values; we see Java's default values when no value is given (null, 0, 0.0, false) and why assigning the wrong type causes an error.
From Zero to Spring Boot series episode 2 is live on the Opendart Akademi YouTube channel. This series is prepared from the recorded sessions of our live Java Spring Boot course; we start from the basics of Java and progress toward Spring Boot.
▶ Watch the lesson on YouTubeAll episodes in the series
What's in this lesson?
- 00:00 Introduction
- 00:03 Class start and end scope
- 00:38 Variables are a bucket
- 01:05 Access modifiers and public
- 02:14 Variable declaration rule: access modifier, data type, name; String
- 02:57 Assignment with "="
- 03:57 String variable without a value: null
- 04:28 Integers with int
- 05:14 Wrong type value: "Type mismatch" error, Java is a type-safe language
- 06:43 Why choosing the correct data type matters (database and memory)
- 08:01 byte and other small types
- 09:23 Primitive data types: short, long, float, char, unsigned
- 10:47 Decimal numbers with double
- 11:53 boolean: true / false
- 12:36 Summary: describing a real-world object with variables
- 13:14 Closing
Opendart Akademi
Learn Spring Boot with an instructor in live classes
These videos are from the recorded sessions of our Java Spring Boot course. The full course covers Java, Spring Boot, REST API, databases and real projects; you can ask the instructor when you get stuck.
← Previous episode: What is Abstraction? Creating the First Package and Class in Java · Playlist: From Zero to Spring Boot · Subscribe on YouTube
Instructor: İbrahim Gökyar (Opendart Akademi)


