0% found this document useful (0 votes)
4 views

Java Programming Notes

Uploaded by

maneeshchaube5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Java Programming Notes

Uploaded by

maneeshchaube5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java Programming Notes

1. Introduction to Java

Java is a high-level, class-based, object-oriented programming language that is designed to have as few

implementation dependencies as possible.

Example:

public class HelloWorld {

public static void main(String[] args) {

System.out.println("Hello, World!");

2. Data Types and Variables

Java supports several data types like int, float, double, char, boolean, etc.

Example:

int age = 25;

double salary = 50000.50;

boolean isEmployed = true;

3. Control Statements

Java has control statements like if, if-else, switch, for, while, and do-while.

Example:

int number = 10;


Java Programming Notes

if(number > 0) {

System.out.println("Positive number");

4. Object-Oriented Programming

Java supports OOP concepts: Class, Object, Inheritance, Polymorphism, Encapsulation, and Abstraction.

Example:

class Animal {

void sound() {

System.out.println("Animal sound");

class Dog extends Animal {

void sound() {

System.out.println("Bark");

5. Arrays and Strings

Arrays store multiple values in a single variable.

Strings are objects that represent sequences of characters.

Example:
Java Programming Notes

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

String name = "Java";

6. Exception Handling

Exception handling in Java is managed via try, catch, throw, throws, and finally.

Example:

try {

int result = 10 / 0;

} catch (ArithmeticException e) {

System.out.println("Cannot divide by zero");

7. File Handling

Java provides java.io and java.nio packages for file operations.

Example:

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

writer.write("Hello File");

writer.close();

8. Collections Framework

Java Collections include List, Set, Map, etc.


Java Programming Notes

Example:

List<String> list = new ArrayList<>();

list.add("Apple");

list.add("Banana");

9. Multithreading

Java supports multithreading using the Thread class or Runnable interface.

Example:

class MyThread extends Thread {

public void run() {

System.out.println("Thread running");

10. Java 8 Features

Java 8 introduced features like Lambda expressions, Stream API, Functional interfaces.

Example:

List<String> names = Arrays.asList("John", "Jane", "Jack");

names.forEach(name -> System.out.println(name));

You might also like