Basic Java Notes
1. Introduction to Java
• Java is a high-level, object-oriented programming language.
• It was developed by Sun Microsystems and later acquired by Oracle.
• Java programs can run on any system using the Java Virtual Machine (JVM).
• Java follows the principle: Write Once, Run Anywhere.
2. Features of Java
• Platform Independent
• Object Oriented
• Secure
• Robust
• Multithreaded
• Portable
3. Structure of a Java Program
• A Java program usually contains a class definition.
• The main() method is the entry point of the program.
• Syntax example: public static void main(String[] args)
4. Basic Java Program Example
• public class HelloWorld {
• public static void main(String[] args) {
• [Link]("Hello World");
• }
• }
5. Data Types in Java
• int – integer numbers
• float – decimal numbers
• double – large decimal numbers
• char – single character
• boolean – true or false
• String – sequence of characters
6. Operators in Java
• Arithmetic Operators: +, -, *, /, %
• Relational Operators: ==, !=, >, <, >=, <=
• Logical Operators: &&, ||, !
7. Control Statements
• if statement
• if-else statement
• switch statement
• for loop
• while loop
• do-while loop
8. Object Oriented Concepts
• Class – blueprint for objects
• Object – instance of a class
• Encapsulation – wrapping data and methods together
• Inheritance – acquiring properties of another class
• Polymorphism – one method with different behaviors