Java is a high-level, object-oriented, platform-independent programming language developed by James Gosling in 1995, renowned for its "write once, run anywhere" (WORA) capability via the JVM. Key features include simplicity, robustness, security, and support for multithreading. Java consists of the...
Java Programming:
Comprehensive Notes
1. Introduction to Java
Java is a high-level, object-oriented, platform-independent programming
language. It was developed by James Gosling at Sun Microsystems (now
part of Oracle) and released in 1995. Java is known for its "write once, run
anywhere" (WORA) philosophy, thanks to the JVM (Java Virtual Machine).
Developed by: James Gosling
Released: 1995
Paradigm: Object-Oriented Programming (OOP)
Platform Independence: Java bytecode runs on the JVM, making it platform-
agnostic.
2. Features of Java
Simple: Java’s syntax is clean, similar to C++, but without complex features like
pointers.
Object-Oriented: Everything is treated as an object, making development
modular.
Platform-Independent: Java code is compiled into bytecode, which runs on any
system with JVM.
Robust: It handles memory management, exceptions, and garbage collection,
which reduces the chances of errors.
Multithreaded: Java supports concurrent execution of two or more parts of a
program.
Secure: Java provides a secure execution environment through the Java Security
Manager and bytecode verification.
3. Java Development Kit (JDK) and Java Runtime
Environment (JRE)
JDK (Java Development Kit): The full development environment for building
Java applications. It includes the compiler ( javac), interpreter (java), and
libraries.
JRE (Java Runtime Environment): Provides the libraries, JVM, and other
components to run Java applications. It doesn’t include development tools.
, 4. Basic Syntax in Java
A simple Java program:
java
Copy code
public class HelloWorld { public static void main(String[] args)
{ System.out.println( "Hello, World!" ); } }
Key components:
public class HelloWorld: Defines a class called HelloWorld.
public static void main(String[] args): Entry point of the Java application.
System.out.println("Hello, World!"): Outputs text to the console.
5. Data Types in Java
Java supports primitive and reference data types.
Primitive Data Types:
Data Type Description Size
byte 8-bit integer 1 byte
short 16-bit integer 2 bytes
int 32-bit integer 4 bytes
long 64-bit integer 8 bytes
float Single-precision float 4 bytes
double Double-precision float 8 bytes
char 16-bit Unicode char 2 bytes
boolean true/false 1 bit
Reference Data Types:
Objects: Instances of classes.
Arrays: Collection of elements of the same type.
6. Variables and Constants
In Java, variables can be of three types:
Instance Variables: Declared inside a class but outside any method.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller sarita1. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.39. You're not tied to anything after your purchase.