Home » Core Java

Core Java

Java 8 Anonymous Function Example

java-logo

1. Introduction Java is an object Oriented Programming Language, and as such concepts like Encapsulation and Abstraction sits at the heart of it. However, since Java is a bit-too-much Object Oriented at its genome structure, that often times than not, it adds a lot of verbosity and boiler plate to its language constructs. Even simple, trivial requirement of creating an ...

Read More »

JAVA ActionEvent Example

java-logo

1. Introduction An Action can be used to separate functionality and state from a component. For example, if you have two or more components that perform the same function, consider using an Action object to implement the function. An Action object is an action listener that provides not only action-event handling, but also centralized handling of the state of action-event-firing ...

Read More »

Mockito Mock Database Connection Example

mockito-logo

A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. In this example we will learn how to write a simple test case using Mockito. Tools and technologies used in this example are Java 1.8, Eclipse ...

Read More »

Java 8 Array to Stream Example

java-logo

1. Introduction Official javadoc of java.util.stream.Stream states that it is “A sequence of elements supporting sequential and parallel aggregate operations”. And such every Stream is backed by a source which would provide the Stream with its “sequence of elements”. In Java, like most other programming languages, sequence of elements is generally provided via two constructs: (i) the java.util.Collection instances and ...

Read More »

Java Nio Read File Example

java-logo

With this example we are going to demonstrate how to use the Non-blocking I/O API, or NIO.2 API (NIO API) for short, to read the contents of a file. The examples in this article are compiled and run in a Mac OS unix environment. Please note that Java SE 8 is required to run the code in this article. 1. Introduction ...

Read More »

Mockito List Matcher Example

mockito-logo

In the Mockito Tutorial for Beginners, we saw a general overview of the use of Mockito framework for Java unit tests. In this example,we will see how are and how to use the Mockito Matchers for List elements. For this example, we will use: Java 1.7.0 Eclipse Mars 2, release 4.5.2. JUnit 4. Mockito 1.10.19. Tip You may skip project ...

Read More »

Mockito Test Case Example

mockito-logo

A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. In this example we will learn how to write a simple test case using Mockito. Tools and technologies used in this example are Java 1.8, Eclipse ...

Read More »

Java 8 Date and Time API Tutorial

java-logo

JDK 1.0 had java.util.Date class giving access to Java’s first Date API. However soon after its usage, it started to show cracks of problems on its brittle surface. It did not take any longer to realize that java.util.Date was not thread-safe! Table Of Contents 1 . Introduction 2. The new Date and Time API 2.1 LocalDate 2.2 LocalTime 2.3 Amalgamating ...

Read More »

Mockito: How to mock a void method call

mockito-logo

A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. In this example we will learn how to mock a void method call using Mockito. Tools and technologies used in this example are Java 1.8, Eclipse ...

Read More »

JAVA Swing Menu Example

java-logo

1. Introduction A menu provides a space-saving way to let the user choose one of several options. Other components with which the user can make a one-of-many choices include, combo boxes, lists, radio buttons, spinners, and tool bars. Menus are unique in that, by convention, they aren’t placed with the other components in the UI. Instead, a menu usually appears ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns