0% found this document useful (0 votes)
3 views3 pages

Java Master Guide

The document is a comprehensive Java Master Guide covering fundamental concepts such as variables, data types, operators, control flow, loops, arrays, strings, methods, object-oriented programming, exception handling, collections, and file handling. It includes code examples for each topic to illustrate key points. The guide emphasizes Java's platform independence and core programming principles.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Java Master Guide

The document is a comprehensive Java Master Guide covering fundamental concepts such as variables, data types, operators, control flow, loops, arrays, strings, methods, object-oriented programming, exception handling, collections, and file handling. It includes code examples for each topic to illustrate key points. The guide emphasizes Java's platform independence and core programming principles.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java Master Guide

1. Introduction to Java
- Java is a high-level, object-oriented, platform-independent programming language.
- WORA: Write Once, Run Anywhere (due to JVM).

public class HelloWorld {


public static void main(String[] args) {
System.out.println("Hello, Rohith Ji!");
}
}

2. Variables & Data Types


- int, float, char, double, boolean, String

int age = 21;


String name = "Rohith";
boolean isKing = true;

3. Operators & Control Flow


- Arithmetic, Relational, Logical
- if-else, switch-case

if(age > 18) {


System.out.println("Adult");
} else {
System.out.println("Minor");
}

4. Loops
- for, while, do-while

for(int i = 1; i <= 5; i++) {


System.out.println(i);
}
5. Arrays & Strings

int[] arr = {1, 2, 3};


String str = "Rohith";
System.out.println(str.length());

6. Methods

public static int add(int a, int b) {


return a + b;
}

7. OOP Concepts
- Class, Object, Inheritance, Polymorphism, Encapsulation, Abstraction

class Animal {
void sound() {
System.out.println("Animal sound");
}
}
class Dog extends Animal {
void sound() {
System.out.println("Bark");
}
}

8. Exception Handling

try {
int x = 10 / 0;
} catch(Exception e) {
System.out.println("Error: " + e);
}

9. Collections
- ArrayList, HashMap
ArrayList<String> list = new ArrayList<>();
list.add("Java");
HashMap<String, Integer> map = new HashMap<>();
map.put("Rohith", 1);

10. File Handling

FileWriter writer = new FileWriter("data.txt");


writer.write("Hello, Rohith!");
writer.close();

You might also like