Skip to content

saitejar110507/Learn-Java-With-Me-2.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

☕ JAVA PROGRAMMING LANGUAGE

📌 Introduction to Programming Language

Programming languages differ from natural languages in that natural languages are used for interaction between people, while programming languages are designed to allow humans to communicate instructions to machines.

🚀 Java Programming Language

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

🛠 Main Features of Java

Java is a general-purpose programming language intended to let programmers "write once, run anywhere," meaning that compiled Java code can run on all platforms that support Java without the need to recompile.

📜 Birth Of Java

Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991. It took 18 months to develop the first working version. This language was initially called "Oak," but was renamed "Java" in 1995. Between the initial implementation of Oak in 1992 and the public announcement of Java in 1995, many more people contributed to the design and evolution of the language.

🎯 Principles of Java

There were five primary goals in creating the Java language:

  1. ✅ It must be simple, object-oriented, and familiar.
  2. 🔒 It must be robust and secure.
  3. 🌍 It must be architecture-neutral and portable.
  4. ⚡ It must execute with high performance.
  5. 🔄 It must be interpreted, threaded, and dynamic.

🌐 How Java Impacted the Internet

Java simplified web programming and introduced a new type of networked program called the Applet, which changed online content delivery. Java also addressed issues such as portability and security.

📌 Java Applet

  • Java Applets: Java programs running in browsers, enabling interactive web features.
  • Execution: Automatically runs in a browser when loaded from a link.
  • Purpose: Handles client-side tasks like displaying data or simple calculations, reducing server load.
  • Dynamic Nature: Applets function as active programs, executing on the client side after server initiation.
  • Decline: Phased out from JDK 9, fully removed by JDK 11 due to technological shifts.

💡 Fun Fact: JavaScript was named after Java, but they are different languages.

🏢 Who Owns Java Now?

Java is owned by Oracle, and more than 3 billion devices run Java.

🔍 Uses Of Java

  • 📱 Mobile applications (especially Android apps)
  • 💻 Desktop applications
  • 🌍 Web applications
  • 🔗 Web servers and application servers
  • 🎮 Games
  • 📊 Database connection
  • And much more!

🏷 Versions of Java

Version Release Date
JDK Beta 1995
JDK 1.0 January 23, 1996
JDK 1.1 February 19, 1997
J2SE 1.2 December 8, 1998
J2SE 1.3 May 8, 2000
J2SE 1.4 February 6, 2002
J2SE 5.0 September 30, 2004
Java SE 6 December 11, 2006
Java SE 7 July 28, 2011
Java SE 8 (LTS) March 18, 2014
Java SE 9 September 21, 2017
Java SE 10 March 20, 2018
Java SE 11 (LTS) September 25, 2018
Java SE 12 March 19, 2019
Java SE 13 September 17, 2019
Java SE 14 March 17, 2020
Java SE 15 September 15, 2020
Java SE 16 March 16, 2021
Java SE 17 (LTS) September 14, 2021
Java SE 18 March 22, 2022
Java SE 19 September 20, 2022
Java SE 20 March 21, 2023
Java SE 21 (LTS) September 19, 2023
Java SE 22 March 19, 2024
Java SE 23 September 17, 2024

📝 Java Syntax Reference

  • Java's syntax is heavily influenced by C and C++.
  • Java is almost entirely object-oriented, with all code inside classes. Primitive types (int, float, boolean, char) are exceptions for performance.
  • Java includes some C++ features, like printf().
  • ⚠ Java does not support operator overloading or multiple inheritance for classes (only for interfaces).

🏷 Comment Styles

  • Single-line: //
  • Multi-line: /* ... */
  • Javadoc: /** ... */ for documentation generation.

⚙ Getting Started with Java

🖥 Installing JDK in System

  1. Download JDK from Oracle's official website.
  2. Run java -version in the terminal to check installation.

🚀 First Java Program

/* Example.java */
class Example {
    public static void main(String args[]) {
        System.out.println("This is a simple Java program.");
    }
}

Running the program:

javac Example.java
java Example

Output:

This is a simple Java program.

⚠ Important Notes

  • ✅ Source code should have a .java extension.
  • ✅ The terminal should be opened in the directory where the file is saved.
  • ⚠ Java is case-sensitive: MyClass and myclass are different.
  • 🔠 Identifiers such as AB, Ab, aB, and ab are distinct in Java.

🔍 Observing the Code

📝 Comments in Java

Three types of comments in Java:

  1. Single-line Comment: // This is a comment.

  2. Multi-line Comment: java /* This is a multi-line comment. It spans multiple lines. */

  3. Documentation Comment: java /** This is a Javadoc comment. */

🔹 Source File Name

  • The name of a source file should match the public class name with a .java extension.

🔹 Class Syntax { }

  • All program activity occurs within { - start, } - end.
  • The first letter of the class should be uppercase (though lowercase is allowed but discouraged).

🔹 Key Concepts

  • public: Access modifier allowing visibility from outside the class.
  • static: Allows calling main() without creating an instance of the class.
  • void: Indicates that main() does not return a value.
  • Parameters: String args[] allows passing command-line arguments.
  • System.out.println(): Prints output to the console.
  • Semicolon ;: Required at the end of most Java statements.

📺 Didn’t understand? No problem: Watch a video tutorial.