Java Basics - Simple Notes
Java Basics - Simple Notes
2. Setting Up Java
Install Java: Download the JDK (Java Development Kit).
Use an IDE (like Eclipse or IntelliJ) to write your code.
3. Basic Syntax
Hello World Example:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
This prints "Hello, World!" on the screen.
6. Methods (Functions)
Method Definition: A method does something and can return a result.
public static int addNumbers(int a, int b) {
return a + b;
}
Calling the method:
int result = addNumbers(5, 3);
System.out.println(result); // Output: 8
9. Collections
ArrayList stores a list of items.
ArrayList<String> list = new ArrayList<>();
list.add("Java");
list.add("Python");
Key Points:
Java is case-sensitive.
The main method is where the program starts.
System.out.println() is used to print things to the screen.
This version is simpler and easier to understand. Copy this into a text editor and save it as a PDF,
and you'll have your Java notes! Let me know if you need more help!