This post shows an example of a bad practice I saw in one of my Java projects seven years ago. It also has a naive implementation of concurrency in Java, wherein it waits for all threads to complete. Moreover, it
How To Use Java 8 Stream Reduce Example
This post shows how to use Java Stream Reduce with example codes. The idea of the reduce operation is the generation of a single result from a collection of values or objects. It is similar to the min and max operations
Java 8 – Convert Iterator to Stream Using StreamSupport
Although not a common scenario, some libraries return Iterators instead of Stream or Collection objects. Why? Because they can. If the Java libraries you are using have methods that return Iterator objects, this will show how to convert Iterator to
Java – Closing JDBC Database Resources with try-with-resources
This post demonstrates how to use Java JDBC API with try-with-resources database resources in the following order – ResultSet, Statement, and Connection. The try-with-resources is a new exception handling mechanism that makes it easier to correctly close resources used within
Chapter 7: Java Classes And Access Modifiers – Review
Java classes and their variables and methods can use access modifiers – private, public, protected, and package-level (no keyword). These access modifiers set the classes’ visibility, constructors, and instance or class variables and methods to the other parts of the
ExecutorService, AutoCloseable, and Try-With-Resources In Java
This post demonstrates how to use Java ExecutorService and AutoCloseable with try-with-resources. With ExecutorService, we need to call the shutdown method all the time. However, call the shutdown method means we are writing more codes than we should. There has
Chapter 3: How To Write Your First Java Program
How to write your first Java program? If you’re starting out learning Java, this probably is the first question you’d ask yourself. But before writing a Java program, you need to install the Java Development Kit for your operating system,
Chapter 1: Introduction to Java as Language and Platform
When we say “Java,” we refer to the Oracle technology with two aspects – Java as a programming language and Java as a platform. Java as a programming language allows us to create Java programs, while Java as an environment
Chapter 4: Oracle JDK8 on Windows 10: Installation
This post demonstrates how to install Oracle JDK8 on Windows 10. Download JDK8 From Oracle First, go to www.google.com and search for “Java JDK 8”. Then, click the link that says “Java SE Development Kit 8 – Downloads“. Once you’re
Chapter 5: Java Classes – The Blueprints And Building Blocks
In How To Write Your First Java Program, we installed an IDE and wrote a basic Java program. We also learned about the essential components of that program’s Java source codes – the keyword class and the main method. Here