Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Java Language Fundamentals and Core Concepts

Tech 1

Java Version History

Version Release Date Key Notes
Java 1.0 1996.01.23 Sun Microsystems released the first Java Development Kit (JDK).
Java 1.1 1997.02.19 JavaOne conference was held, becoming the largest of its kind at the time.
Java 1.2 1998.12.08 Platform split into J2SE (Standard Edition), J2EE (Enterprise Edition), and J2ME (Micro Edition).
Java 1.3 2000.05.08
Java 1.4 2004.02.06
Java 5.0 2004.09.30 ① Version numbering changed from 1.4 to 5.0. ② Platform renamed to Java SE, Java EE, Java ME.
Java 6.0 2006.12.11 Oracle announced the acquisition of Sun Microsystems in 2009.
2009.04.20 Oracle acquired Sun for approximately $74 billion.
Java 7.0 2011.07.02
Java 8.0 2014.03.18 The most significant update since Java 5.0. A Long-Term Support (LTS) release.
Java 9.0 2017.09.22 Six-month release cadence begins. ② Java 9.0 drops support for 32-bit Windows.
Java 10.0 2018.03.21
Java 11.0 2018.09.25 JDK installer no longer includes a separate JRE package. An LTS release.
Java 12.0 2019.03.19
Java 17.0 2021.09 Java 17.0 released, also versioned as 21.9. An LTS release.
Java 19.0 2022.09 Java 19.0 released, also versioned as 22.9.

Java Language Characteristics

Strengths:

  1. Platform Independence: A single compiled Java program can run on any system with a compatible Java Virtual Machine (JVM), adhering to the principle of "write once, run anywhere."
  2. Object-Oriented: Built around the principles of encapsulation, inheritance, and polymorphism, which promotes modular, maintainable, and scalable software design.
  3. Robustness: Eliminates error-prone features like explicit pointers and manual memory manaegment found in languages like C/C++, providing automatic garbage collection.
  4. Security: The JVM's sandbox model and bytecode verification provide a secure execution environment.
  5. High Performance: Utilizes Just-In-Time (JIT) compilation to translate bytecode into native machine code for efficient execution.
  6. Rich Ecosystem: A vast colleciton of mature, open-source libraries and frameworks.

Weaknesses:

  1. Verbose Syntax: The language can be more verbose and ceremonious compared to some modern languages.
  2. Memory Footprint: The runtime environment and typical enterprise frameworks can be resource-intensive.

The Java Virtual Machine (JVM)

The JVM is a virtual computing environment that executes Java bytecode. Its primary functions are:

  1. Providing platform independence by acting as an abstraction layer over the underlying hardware and OS.
  2. Managing memory automatically through allocation and garbage collection.

Q: Can Java programs still experience memory leaks or out-of-memory errors? A: Yes. While automatic garbage collection handles most memory management, logic errors (e.g., holding object references unnecessarily) can still lead to memory issues.

Common Command-Line Operations

# 1. Compile a Java source file
javac MyProgram.java

# 2. Run the compiled bytecode
java MyProgram

# 3. Run a single-file source program directly (Java 11+)
java MyProgram.java

Java Program Structure and Basics

Source File Rules:

  • A .java file may contain multiple class definitions.
  • Only one class can be declared public per file.
  • The public class name must match the source filename.

The main Method: The entry point for a Java application. Its signature is fixed:

public static void main(String[] args) { // Standard signature
    // Program logic here
}
// Alternative valid signatures for the parameter:
// public static void main(String args[])
// public static void main(String[] a)

Output Statements:

System.out.println("Text"); // Prints text and moves to a new line.
System.out.print("Text");   // Prints text without a newline.
// Common escape sequences:
System.out.println("Line1\nLine2"); // Newline
System.out.println("Column1\tColumn2"); // Tab

Comments:

// Single-line comment

/*
 Multi-line
 comment
*/

/**
 * Documentation comment (Javadoc).
 * @param args command-line arguments
 */

Identifiers

Rules:

  • Can contain letters, digits, underscore (_), and dollar sign ($).
  • Cannot start with a digit.
  • Cannot be a Java keyword (e.g., class, public) or literal (true, false, null).
  • Case-sensitive.

Conventions:

  • Class/Interface Names: PascalCase (e.g., MainApplication).
  • Method/Variable Names: camelCase (e.g., calculateTotal).
  • Constant Names: UPPER_SNAKE_CASE (e.g., MAX_SIZE).
  • Package Names: All lowercase (e.g., com.example.project).

Data Types

Primitive Types (8):

  • Integer: byte, short, int, long
  • Floating-point: float, double
  • Boolean: boolean
  • Character: char

Reference Types:

  • Any non-primitive type, including:
    • Class types (e.g., String)
    • Array types (e.g., int[])
    • Interface types

Environment Variable Configuration

Purpose: To allow the java and javac commands to be executed from any terminal location.

Configuration Method (Windows):

  1. Create JAVA_HOME: Add a new system variable.
    • Variable Name: JAVA_HOME
    • Variable Value: Path to your JDK installation directory (e.g., C:\Program Files\Java\jdk-17).
  2. Update Path: Edit the Path system variable and add a new entry: %JAVA_HOME%\bin.

Verification: Open a new command prompt and run java -version and javac -version.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.