JAVA BASICS - LESSON 1 (From Scratch)
1. What is Java?
Java is a high-level, object-oriented programming language used to build web applications, mobile
apps, desktop software, and enterprise systems.
2. Install Java (JDK)
To start coding in Java, you must install the JDK (Java Development Kit). After installing, verify
using command: javac -version
3. First Java Program
public class Main {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}
Explanation: public class Main → Class name main() → Starting point of program
[Link]() → Prints output to screen
4. Variables in Java
int age = 20;
double salary = 25000.50;
char grade = 'A';
boolean isPassed = true;
String name = "Mohith";
5. Basic Data Types
• int → Whole numbers
• double → Decimal numbers
• char → Single character
• boolean → true/false
• String → Text
6. User Input Example
import [Link];
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter your name: ");
String name = [Link]();
[Link]("Hello " + name);
}
}
Practice Tasks
• Print your name and age.
• Create variables for 3 subjects and print total marks.
• Take user input and print square of a number.
End of Lesson 1. Practice daily. Brick by brick.