Hey everyone! We're starting again from Day 1 so everyone can build a strong foundation by learning everything from the basics this time.
๐2
๐ **Day 1: Introduction to Java with Hello World!** ๐
๐ Welcome to the very first day of our exciting Java Learning Series! ๐ Today, we're taking our initial steps into the powerful world of Java programming. We'll start with the absolute basics: understanding the structure of a simple Java program and making it say that classic greeting: "Hello, World!" Get ready to write your first lines of code and witness them in action! Let's dive in! ๐ป
---
**Your First Java Code:**
Here's the quintessential "Hello World" program in Java. Don't worry if it looks a bit complex at first; we'll break down each part in future lessons!
```java
public class HelloWorld {
public static void main(String[] args) {
// This line prints "Hello, World!" to the console
System.out.println("Hello, World!");
}
}
```
---
**Output example:**
```
Hello, World!
```
---
**๐ก Small Challenge for You!**
Your first programming challenge: Can you modify the line `System.out.println("Hello, World!");` in the code above to print "Hello, [Your Name]!" instead? Give it a try and see your personalized message appear in the console! ๐ค Share your output in the comments!
---
๐ Welcome to the very first day of our exciting Java Learning Series! ๐ Today, we're taking our initial steps into the powerful world of Java programming. We'll start with the absolute basics: understanding the structure of a simple Java program and making it say that classic greeting: "Hello, World!" Get ready to write your first lines of code and witness them in action! Let's dive in! ๐ป
---
**Your First Java Code:**
Here's the quintessential "Hello World" program in Java. Don't worry if it looks a bit complex at first; we'll break down each part in future lessons!
```java
public class HelloWorld {
public static void main(String[] args) {
// This line prints "Hello, World!" to the console
System.out.println("Hello, World!");
}
}
```
---
**Output example:**
```
Hello, World!
```
---
**๐ก Small Challenge for You!**
Your first programming challenge: Can you modify the line `System.out.println("Hello, World!");` in the code above to print "Hello, [Your Name]!" instead? Give it a try and see your personalized message appear in the console! ๐ค Share your output in the comments!
---
โค1
What is the primary purpose of the line `System.out.println("Hello, World!");` in the Java 'Hello World' program?
Anonymous Quiz
3%
To declare a new class named `HelloWorld`.
94%
To display text output (like "Hello, World!") on the console.
3%
To define the main entry point of the Java program.
0%
To import necessary libraries for printing.
๐ Day 2: Variables and Data Types! ๐
Ready to store information in your Java programs? Today, we dive into the fundamental concepts of Variables and Data Types. Think of variables as named containers for different kinds of data, from numbers to text and true/false values. Understanding them is key to writing dynamic and powerful code! Let's get started and see how Java handles different types of information. ๐ก๐
```java
public class Day2Variables {
public static void main(String[] args) {
// Declaring and initializing different types of variables
// 1. Integer (whole numbers)
int age = 30;
System.out.println("My age is: " + age); // Output: My age is: 30
// 2. Double (floating-point numbers, e.g., decimals)
double price = 19.99;
System.out.println("The product price is: $" + price); // Output: The product price is: $19.99
// 3. Boolean (true or false)
boolean isJavaFun = true;
System.out.println("Is Java fun? " + isJavaFun); // Output: Is Java fun? true
// 4. Character (single character)
char initial = 'J';
System.out.println("My initial is: " + initial); // Output: My initial is: J
// 5. String (sequence of characters - technically a class, but acts like a primitive for beginners)
String userName = "CodeMaster7";
System.out.println("Username: " + userName); // Output: Username: CodeMaster7
// You can also change variable values
age = 31; // Age is now updated
System.out.println("Updated age: " + age); // Output: Updated age: 31
// Simple arithmetic with variables
int num1 = 10;
int num2 = 5;
int sum = num1 + num2;
System.out.println("Sum of " + num1 + " and " + num2 + " is: " + sum); // Output: Sum of 10 and 5 is: 15
}
}
```
Output example:
```
My age is: 30
The product price is: $19.99
Is Java fun? true
My initial is: J
Username: CodeMaster7
Updated age: 31
Sum of 10 and 5 is: 15
```
โจ **Your Small Challenge:**
Create a new Java program. Declare a `float` variable (remember to add 'f' at the end of the number, e.g., `3.14f`) to store the value of Pi. Then, declare an `int` variable for a radius. Calculate the area of a circle (`Pi * radius * radius`) and print the result to the console! Don't forget to use appropriate data types for your variables. Good luck! ๐ฏ
---
Ready to store information in your Java programs? Today, we dive into the fundamental concepts of Variables and Data Types. Think of variables as named containers for different kinds of data, from numbers to text and true/false values. Understanding them is key to writing dynamic and powerful code! Let's get started and see how Java handles different types of information. ๐ก๐
```java
public class Day2Variables {
public static void main(String[] args) {
// Declaring and initializing different types of variables
// 1. Integer (whole numbers)
int age = 30;
System.out.println("My age is: " + age); // Output: My age is: 30
// 2. Double (floating-point numbers, e.g., decimals)
double price = 19.99;
System.out.println("The product price is: $" + price); // Output: The product price is: $19.99
// 3. Boolean (true or false)
boolean isJavaFun = true;
System.out.println("Is Java fun? " + isJavaFun); // Output: Is Java fun? true
// 4. Character (single character)
char initial = 'J';
System.out.println("My initial is: " + initial); // Output: My initial is: J
// 5. String (sequence of characters - technically a class, but acts like a primitive for beginners)
String userName = "CodeMaster7";
System.out.println("Username: " + userName); // Output: Username: CodeMaster7
// You can also change variable values
age = 31; // Age is now updated
System.out.println("Updated age: " + age); // Output: Updated age: 31
// Simple arithmetic with variables
int num1 = 10;
int num2 = 5;
int sum = num1 + num2;
System.out.println("Sum of " + num1 + " and " + num2 + " is: " + sum); // Output: Sum of 10 and 5 is: 15
}
}
```
Output example:
```
My age is: 30
The product price is: $19.99
Is Java fun? true
My initial is: J
Username: CodeMaster7
Updated age: 31
Sum of 10 and 5 is: 15
```
โจ **Your Small Challenge:**
Create a new Java program. Declare a `float` variable (remember to add 'f' at the end of the number, e.g., `3.14f`) to store the value of Pi. Then, declare an `int` variable for a radius. Calculate the area of a circle (`Pi * radius * radius`) and print the result to the console! Don't forget to use appropriate data types for your variables. Good luck! ๐ฏ
---
Which of the following is NOT a primitive data type in Java?
Anonymous Quiz
2%
int
16%
boolean
71%
String
11%
char
Java for beginners pinned ยซHey everyone! We're starting again from Day 1 so everyone can build a strong foundation by learning everything from the basics this time.ยป
Learn Python daily with bite-sized lessons, code examples, output previews, and fun quizzes. Perfect for beginners and enthusiasts!
https://t.me/Python_basic_to_advance
https://t.me/Python_basic_to_advance
Telegram
Python basic to advance
Learn Python daily with bite-sized lessons, code examples, output previews, and fun quizzes. Perfect for beginners and enthusiasts!
๐ Java Learning Series - Day 3! ๐
Ready to make your code *do things*? Today, we're diving into the powerful world of **Operators in Java**! โโโ๏ธโ These special symbols are the backbone of computation and logic, allowing you to perform calculations, make comparisons, and control program flow. Understanding operators is crucial for writing dynamic and interactive Java applications. Let's get started! ๐ช
```java
public class OperatorShowcase {
public static void main(String[] args) {
// 1. Arithmetic Operators (+, -, *, /, %)
int a = 10;
int b = 3;
System.out.println("--- Arithmetic Operators ---");
System.out.println("a + b = " + (a + b)); // Addition: 13
System.out.println("a - b = " + (a - b)); // Subtraction: 7
System.out.println("a * b = " + (a * b)); // Multiplication: 30
System.out.println("a / b = " + (a / b)); // Division (integer): 3
System.out.println("a % b = " + (a % b)); // Modulo (remainder): 1
// 2. Assignment Operators (=, +=, -=, *=, /=, %=)
int c = 5;
c += 2; // Equivalent to c = c + 2;
System.out.println("n--- Assignment Operators ---");
System.out.println("c after c += 2: " + c); // Output: 7
// 3. Relational Operators (==, !=, >, <, >=, <=)
int x = 10;
int y = 5;
System.out.println("n--- Relational Operators ---");
System.out.println("x > y is " + (x > y)); // Output: true
System.out.println("x == y is " + (x == y)); // Output: false
System.out.println("x != y is " + (x != y)); // Output: true
// 4. Logical Operators (&&, ||, !)
boolean isJavaFun = true;
boolean isDay3 = true;
System.out.println("n--- Logical Operators ---");
System.out.println("isJavaFun && isDay3 is " + (isJavaFun && isDay3)); // AND: true
System.out.println("!isJavaFun is " + (!isJavaFun)); // NOT: false
// 5. Unary Operators (++, --)
int i = 7;
i++; // Post-increment: i becomes 8
System.out.println("n--- Unary Operators ---");
System.out.println("i after i++: " + i); // Output: 8
--i; // Pre-decrement: i becomes 7
System.out.println("i after --i: " + i); // Output: 7
}
}
```
Output example:
```
--- Arithmetic Operators ---
a + b = 13
a - b = 7
a * b = 30
a / b = 3
a % b = 1
--- Assignment Operators ---
c after c += 2: 7
--- Relational Operators ---
x > y is true
x == y is false
x != y is true
--- Logical Operators ---
isJavaFun && isDay3 is true
!isJavaFun is false
--- Unary Operators ---
i after i++: 8
i after --i: 7
```
**Small challenge:** ๐ค
What will be the value of `result` after these lines of code?
```java
int num1 = 20;
int num2 = 6;
int result = num1 % num2;
```
Share your answer in the comments below! ๐
---
Ready to make your code *do things*? Today, we're diving into the powerful world of **Operators in Java**! โโโ๏ธโ These special symbols are the backbone of computation and logic, allowing you to perform calculations, make comparisons, and control program flow. Understanding operators is crucial for writing dynamic and interactive Java applications. Let's get started! ๐ช
```java
public class OperatorShowcase {
public static void main(String[] args) {
// 1. Arithmetic Operators (+, -, *, /, %)
int a = 10;
int b = 3;
System.out.println("--- Arithmetic Operators ---");
System.out.println("a + b = " + (a + b)); // Addition: 13
System.out.println("a - b = " + (a - b)); // Subtraction: 7
System.out.println("a * b = " + (a * b)); // Multiplication: 30
System.out.println("a / b = " + (a / b)); // Division (integer): 3
System.out.println("a % b = " + (a % b)); // Modulo (remainder): 1
// 2. Assignment Operators (=, +=, -=, *=, /=, %=)
int c = 5;
c += 2; // Equivalent to c = c + 2;
System.out.println("n--- Assignment Operators ---");
System.out.println("c after c += 2: " + c); // Output: 7
// 3. Relational Operators (==, !=, >, <, >=, <=)
int x = 10;
int y = 5;
System.out.println("n--- Relational Operators ---");
System.out.println("x > y is " + (x > y)); // Output: true
System.out.println("x == y is " + (x == y)); // Output: false
System.out.println("x != y is " + (x != y)); // Output: true
// 4. Logical Operators (&&, ||, !)
boolean isJavaFun = true;
boolean isDay3 = true;
System.out.println("n--- Logical Operators ---");
System.out.println("isJavaFun && isDay3 is " + (isJavaFun && isDay3)); // AND: true
System.out.println("!isJavaFun is " + (!isJavaFun)); // NOT: false
// 5. Unary Operators (++, --)
int i = 7;
i++; // Post-increment: i becomes 8
System.out.println("n--- Unary Operators ---");
System.out.println("i after i++: " + i); // Output: 8
--i; // Pre-decrement: i becomes 7
System.out.println("i after --i: " + i); // Output: 7
}
}
```
Output example:
```
--- Arithmetic Operators ---
a + b = 13
a - b = 7
a * b = 30
a / b = 3
a % b = 1
--- Assignment Operators ---
c after c += 2: 7
--- Relational Operators ---
x > y is true
x == y is false
x != y is true
--- Logical Operators ---
isJavaFun && isDay3 is true
!isJavaFun is false
--- Unary Operators ---
i after i++: 8
i after --i: 7
```
**Small challenge:** ๐ค
What will be the value of `result` after these lines of code?
```java
int num1 = 20;
int num2 = 6;
int result = num1 % num2;
```
Share your answer in the comments below! ๐
---
โค1