Core Java

Java 8 vs Java 12

In this article, we will see a comparison of the Java 8 vs Java 12.

1. What is Java?

Java is a programming language first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet. Java is a high-level, platform-independent, object-oriented, functional programming language and runtime environment. Java applications are typically compiled to bytecode (called class files) that can be executed by a JVM (Java Virtual Machine), independent of computer architecture. The JVM manages memory with the help of a garbage collector (see also garbage-collection) to handle object removal from memory when objects are no longer in use.

2. Java 8 vs Java 12: Head To Head Comparison

Oracle no longer provides a 32-bit Windows download. Java Applet, Java Web Start, Java Plugin, and Java Control Panel are not available in Java 12. JavaFX is no longer included in Java 12. It is now available as a separate download from JAXB and JAX-WS are no longer bundled with Java 12. Support parallel full garbage collection on G1.

2.1 Switch Expression

The most popular feature introduced in Java 12 is the Switch Expression. Let’s compare the old and new switch

package code;

public class ExampleSwitch {

	public static void main(String[] args) {
		int number = 5;
		String result;
		switch (number) {
        case 1:
        case 2:
            result = "one or two";
        case 3:
        	result = "three";
        case 4:
        case 5:
        case 6:
        	result = "four or five or six";
        	result = "unknown";
		System.out.println("Old Syntax : " + result);

		result = switch (number) {
        case 1, 2 -> "one or two";
        case 3 -> "three";
        case 4, 5, 6 -> "four or five or six";
        default -> "unknown";
	System.out.println("New Syntax : " + result);



java 12 vs java 8 - Switch Expression Output.
Fig. 1: Switch Expression Output.

2.2 New String Methods

Java 12 adds a few new methods to the String class: isBlank(), lines(), strip(), stripLeading(), stripTrailing(), and repeat(). Let’s see how we can make use of the new methods to extract non-blank, stripped lines from a multi-line

package code;

import java.util.List;

public class NewStringMethods {

	public static void main(String[] args) {
		String multilineString = "I Ate     \n   \n  a  \n  Big Potato.";
		List lines = multilineString.lines()
		  .filter(line -> !line.isBlank())


java 12 vs java 8 - New String Methods Output
Fig. 2: New String Methods Output.

3. What do I have to install, Java 12 or Java 8?

Oracle stopped supporting Java 8 in January 2019. This isn’t out of the ordinary, it regularly does this for major Java versions after five years of public availability. Lots of things have changed since Java 8: we get releases every 6 months Licensing, updates, and support have changed. Where we get our JDK from has changed. On top of that, of course, there are new language features, including the major changes that went into Java 9. But now that Java 11 has replaced Java 8 as the latest LTS, and now that major libraries, frameworks, and build tools have adopted the latest versions of Java, it is a good time to migrate your application to Java 11 or 12.

5. Download the Source Code

This was a brief comparison between Java 8 and Java 12.

You can download the full source code of this example here: Java 8 vs Java 12

Want to know how to develop your skillset to become a Java Rockstar?

Join our newsletter to start rocking!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Odysseas Mourtzoukos

Mourtzoukos Odysseas is studying to become a software engineer, at Harokopio University of Athens. Along with his studies, he is getting involved with different projects on gaming development and web applications. He is looking forward to sharing his knowledge and experience with the world.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button