Algorithms Class Notes
1. Introduction to Java
Java is a high-level, object-oriented programming language developed by Sun Microsystems.
Key features:
- Platform independent (via JVM)
- Object-oriented
- Strongly typed
- Garbage collection
Popular for building web apps, mobile apps (Android), and enterprise software.
2. Basic Syntax and Data Types
Every Java application starts with a `main` method:
public static void main(String[] args) {
// code
Common data types:
- int, float, double, boolean, char
- Reference types: arrays, classes, interfaces
3. Object-Oriented Programming in Java
Java is built around OOP principles:
- Class & Object
- Inheritance
- Polymorphism
Algorithms Class Notes
- Encapsulation
- Abstraction
Example:
class Car {
String color;
void drive() {}
4. Exception Handling
Java uses try-catch blocks for error handling.
try {
// code that may throw an exception
} catch (Exception e) {
// handle error
Common exceptions: NullPointerException, ArrayIndexOutOfBoundsException, IOException
5. Collections Framework
Java Collections provide data structures like:
- List (ArrayList, LinkedList)
- Set (HashSet, TreeSet)
- Map (HashMap, TreeMap)
Useful for storing and manipulating groups of data.
Algorithms Class Notes
6. Multithreading and Concurrency
Java supports multithreading using the `Thread` class or `Runnable` interface.
Key concepts:
- Thread lifecycle
- Synchronization
- Executor framework