Java 8 (2014) – Lambdas, Streams, Optional Java 9 (2017) – Module System (JPMS) Java 10 (2018) – var (local variable type inference) Java 11 (2018, LTS) – New String APIs, HTTP Client Java 12 (2019) – Switch expressions (preview) Java 13 (2019) – Text Blocks (preview) Java 14 (2020) – Records (preview), Helpful NPEs Java 15 (2020) – Text Blocks (final), Sealed classes (preview) Java 16 (2021) – Records (final), Pattern Matching for instanceof Java 17 (2021, LTS) – Sealed classes (final), strong encapsulation Java 18 (2022) – Simple web server, UTF-8 by default Java 19 (2022) – Virtual Threads (preview), Loom progress Java 20 (2023) – Scoped Values (incubator) Java 21 (2023, LTS) – Virtual Threads (final), Pattern Matching everywhere 🎉 Java keeps getting simpler, faster, and more expressive—especially with Virtual Threads & pattern matching. #Java #JVM #Programming #SoftwareEngineering #LTS #TechGrowth
Java Evolution: Virtual Threads & Pattern Matching
More Relevant Posts
-
📌 HttpClient in Java 11 – Finally, a Modern Way to Make HTTP Calls 🚀 If you're still using HttpURLConnection in Java… It’s time to upgrade. 👉 Introduced in Java 11 👉 Part of java.net.http package 👉 Modern replacement for HttpURLConnection And yes — it’s much cleaner. 🤯 The Old Way (HttpURLConnection) - Verbose - Hard to read - Manual stream handling - Not very intuitive Making a simple GET request felt complicated. 🚀 The Modern Way (HttpClient – Java 11) HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://example.com")) .GET() .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); Clean. Readable. Modern. 🔥 What Makes It Powerful? - Supports HTTP/2 - Built-in asynchronous calls - CompletableFuture support - WebSocket support - Cleaner API design 🧠 Async Example client.sendAsync(request, HttpResponse.BodyHandlers.ofString()) .thenApply(HttpResponse::body) .thenAccept(System.out::println); No third-party libraries needed. #Java #Java11 #BackendDevelopment #SoftwareEngineering #InterviewPreparation
To view or add a comment, sign in
-
-
📌 Can We Use try and finally Without catch in Java? Yes, Java allows using try and finally without a catch block. Example: try { // code that may throw an exception } finally { // cleanup code } 1️⃣ Why This Is Allowed • The finally block is meant for cleanup • Java guarantees finally execution • Exception handling can be deferred to the caller 2️⃣ What Happens If an Exception Occurs • Exception is thrown from try • finally block executes • Exception propagates to the calling method 3️⃣ When This Pattern Is Useful • Resource cleanup when you don't want to handle the exception locally • Logging or releasing locks • Framework-level code where exception handling is centralized 4️⃣ Important Rule • The exception is NOT swallowed • finally does not handle the exception • Caller must handle or declare it 5️⃣ Example Flow try → finally → caller 🧠 Key Takeaways • catch is optional • finally is optional • try is mandatory when using either • finally executes even when an exception is thrown Using try–finally helps ensure cleanup without forcing local exception handling. #Java #CoreJava #ExceptionHandling #Programming #BackendDevelopment
To view or add a comment, sign in
-
🔹 Java Concept – User Defined (Custom) Exception Today I practiced creating my own Custom Exception in Java instead of using only built-in exceptions. In real applications, sometimes Java’s predefined exceptions are not enough. So we can create our own exception class based on our business rule. 🔹 What I implemented I created a class: RadiusException extends Exception This exception is thrown whenever a negative radius is given to a Circle object. 🔹 Program Logic • Created a Circle class with a radius variable • If radius is positive → calculate Area & Perimeter • If radius is negative → throw RadiusException So the program checks: 👉 A circle cannot have negative radius 🔹 Methods I tested printArea() → calculates area printPerimeter() → calculates perimeter If radius < 0: Program throws and catches my custom exception and prints a proper message instead of crashing. 🔹 What I learned • How to create a User Defined Exception • class MyException extends Exception • Using throw keyword to raise exception • Using try-catch to handle it • Validating data using programming rules This made me understand that exceptions are not only for system errors… We can also use them to enforce real-world constraints inside programs ✔ Special thanks to my mentors for guidance Saketh Kallepu Anand Kumar Buddarapu Uppugundla Sairam @Codegnan #Java #CustomException #ExceptionHandling #OOP #JavaProgramming #CodingPractice #LearningJourney
To view or add a comment, sign in
-
-
📌 start() vs run() in Java Threads Understanding the difference between start() and run() is essential when working with threads in Java. 1️⃣ run() Method • Contains the task logic • Calling run() directly does NOT create a new thread • Executes like a normal method on the current thread Example: Thread t = new Thread(task); t.run(); // no new thread created 2️⃣ start() Method • Creates a new thread • Invokes run() internally • Execution happens asynchronously Example: Thread t = new Thread(task); t.start(); // new thread created 3️⃣ Execution Difference Calling run(): • Same call stack • Sequential execution • No concurrency Calling start(): • New call stack • Concurrent execution • JVM manages scheduling 4️⃣ Common Mistake Calling run() instead of start() results in single-threaded execution, even though Thread is used. 🧠 Key Takeaway • run() defines the task • start() starts a new thread Always use start() to achieve true multithreading. #Java #Multithreading #Concurrency #CoreJava #BackendDevelopment
To view or add a comment, sign in
-
📌 wait(), notify(), notifyAll() in Java — Thread Communication In multithreading, sometimes threads need to coordinate with each other instead of just locking resources. Java provides three important methods for communication: • wait() • notify() • notifyAll() 1️⃣ wait() • Causes the current thread to release the lock • Moves the thread into waiting state • Must be called inside synchronized block 2️⃣ notify() • Wakes up one waiting thread • Does NOT release the lock immediately • The awakened thread waits until lock is available 3️⃣ notifyAll() • Wakes up all waiting threads • Only one will acquire the lock next 4️⃣ Important Rules • These methods belong to Object class • Must be called inside synchronized context • Used for inter-thread coordination 5️⃣ Why They Are Needed Used in scenarios like: • Producer–Consumer problem • Task scheduling • Resource pooling 🧠 Key Takeaway synchronized controls access. wait/notify control communication. Together, they enable proper coordination between threads in Java. #Java #Multithreading #Concurrency #ThreadCommunication #CoreJava
To view or add a comment, sign in
-
📌 wait(), notify(), notifyAll() in Java – Thread Communication In multithreading, sometimes threads need to coordinate with each other instead of just locking resources. Java provides three important methods for communication: • wait() • notify() • notifyAll() 1️⃣ wait() • Causes the current thread to release the lock • Moves the thread into waiting state • Must be called inside synchronized block 2️⃣ notify() • Wakes up one waiting thread • Does NOT release the lock immediately • The awakened thread waits until lock is available 3️⃣ notifyAll() • Wakes up all waiting threads • Only one will acquire the lock next 4️⃣ Important Rules • These methods belong to Object class • Must be called inside synchronized context • Used for inter-thread coordination 5️⃣ Why They Are Needed Used in scenarios like: • Producer–Consumer problem • Task scheduling • Resource pooling 🧠 Key Takeaway synchronized controls access. wait/notify control communication. Together, they enable proper coordination between threads in Java. #Java #Multithreading #Concurrency #ThreadCommunication #CoreJava
To view or add a comment, sign in
-
🚀 Demonstrating Exception Handling and Method Flow in Java As part of my Core Java practice, I developed a program to understand how exception handling works across multiple method calls. The execution flow of the program is: main() → gamma() → beta() → alpha() In the alpha() method, I performed division using user input and handled potential runtime exceptions (such as division by zero) using a try-catch block. Since the exception is handled inside alpha(), it does not propagate further. Through this implementation, I clearly understood: ✔️ How exceptions are handled at the source method ✔️ How control returns safely to beta(), gamma(), and main() after handling ✔️ How exception propagation would occur if the exception was not handled in alpha() ✔️ The importance of structured error handling in writing reliable programs This exercise strengthened my understanding of how Java manages runtime errors and maintains program stability across different layers of execution. Continuously building strong fundamentals in Core Java through hands-on practice. 💻✨ #Java #CoreJava #ExceptionHandling #JavaDeveloper #SoftwareDevelopment #LearningJourney
To view or add a comment, sign in
-
🚀 Java Method Arguments: Pass by Value vs Pass by Reference Ever wondered why Java behaves differently when passing primitives vs objects to methods? 🤔 This infographic breaks it down clearly: ✅ Pass by Value – When you pass a primitive, Java sends a copy of the value. The original variable stays unchanged. ✅ Objects in Java (Copy of Reference) – When you pass an object, Java sends a copy of the reference. You can modify the object’s data, but the reference itself cannot point to a new object. 💡 Why it matters: Prevent bugs when modifying data inside methods Understand how Java handles variables and objects under the hood 🔥 Fun Fact: Even objects are passed by value of reference! Java is always pass by value – whether it’s a primitive or an object. #Java #Programming #CodingTips #JavaDeveloper #SoftwareEngineering #LinkedInLearning #CodeBetter
To view or add a comment, sign in
-
-
Java#00 The lifecycle of an object in Java shows how it "is born," "lives," and "dies" in memory. First, it is created with `new` and occupies space on the Heap. Then, it is used as long as it has valid references. When there are no more references, it becomes inaccessible, and the Garbage Collector kicks in, freeing up the memory it occupied.
To view or add a comment, sign in
-
-
The most common runtime exception in Java? 💥 NullPointerException. The real problem isn’t the exception. It’s returning null.⚠️ When a method returns null, it creates uncertainty. User user = findUserById(id); Looking at this line, we might be confused: • Can user be null? • Is null an expected result? Every caller now has to remember to write defensive code: if (user != null) { System.out.println(user.getName()); } Miss one null check, That’s a runtime failure waiting to happen.🚨 🚀 Enter Optional: Java 8 introduced Optional to make absence explicit. Optional<User> user = findUserById(id); Now the method signature clearly communicates: “This value may or may not be present.” user.ifPresent(u -> System.out.println(u.getName())); User result = user.orElse(new User("Guest")); This makes the code: ✔ More expressive ✔ Cleaner to maintain 💡Note: Optional is powerful when used as a return type. It’s not meant for fields, parameters, or everywhere in your code. Like any tool — it should improve clarity, not add complexity. Do you still return null — or have you moved to Optional? #ModernJava #CodeQuality #CleanCode #JavaDevelopment
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development