Posts

Showing posts with the label Java21

Changing the Default Terminal to Terminator on Ubuntu

Image
Terminator is a powerful tool for developers, allowing you to manage multiple terminal sessions in a single window. Features like splitting panes, tabs, and simultaneous input can significantly boost your productivity. Step 1: Install Terminator First, install Terminator using the apt package manager. sudo apt update sudo apt install terminator -y The -y option automatically answers 'yes' to any prompts during the installation process, streamlining the setup. Step 2: Set as the System Default Ubuntu uses a utility called update-alternatives to manage default applications. We'll use this tool to change the default terminal emulator ( x-terminal-emulator ) to Terminator. Run the Configuration Command Enter the following command in your terminal. A list of available terminals will appear. sudo update-alternatives --config x-terminal-emulator Select Terminator From the resulting list, enter the selection number corresponding to terminator and press Enter. ...

How Modern Java Improves Exception Handling (Java 21)

Image
In recent Java releases, especially Java 21, exception handling mechanisms have been significantly enhanced to improve both code safety and system reliability . These improvements help developers write more robust, maintainable, and error-resilient applications. 1. switch Statements Now Handle null and Support Pattern Matching In Java versions prior to 21, passing a null value to a switch statement would throw a NullPointerException . Java 21 allows developers to explicitly handle null values inside switch , preventing unexpected crashes. switch (input) { case null -> System.out.println("Input is null."); case "YES" -> System.out.println("Yes!"); default -> System.out.println("Other input."); } Benefits Prevents NullPointerException by design Improves clarity and readability 2. Pattern Matching and when Clauses in switch Java 21 introduces pattern matching for switch , allowing developers to write m...