Home » Archives for Mary Zheng

Author Archives: Mary Zheng

Mary Zheng
Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.

Java POJO and Java Bean Example

1. Introduction POJO stands for a Plain Old Java Object. It’s a term coined by Martin Fowler, Rebecca Parsons, and Josh MacKenzie while preparing for a conference in September 2000. POJO is an ordinary Java object which doesn’t tie to any framework or external reference. It has no naming rule for its methods nor data members. Java Bean is a ...

Read More »

Java Array Contains Example

1. Introduction An array is a container object that holds a fixed number of elements with a single type. Java not only provides Arrays to copy, sort, and search elements, it also provides the collection framework to check if a certain value in a collection with the contains method. In this example, I will demonstrate: Find an element in a ...

Read More »

Serializable Java Example – How to serialize and deserialize objects

In this article, we will discuss what is Serializable in Java using examples and how to serialize and deserialize objects. 1. Introduction Serialization is the process of converting an object into a stream of bytes. De-serialization is the reverse process which converts a stream of bytes into an object. Java provides a Serializable marker interface, ObjectInputStream, and ObjectOutputStream classes to ...

Read More »

Default Constructor Java Example

In this post, we feature an example of the Default Constructor in Java. 1. Introduction When the Java compiler compiles the Java source code (.java) into the Java byte code (.class), it will create a public no-argument constructor for the class if it has no constructor defined. This public no-argument constructor is called a default constructor. Its implementation body only ...

Read More »

Java Static Keyword Example

1. Introduction In this post, we feature a comprehensive example of the Java Static Keyword. We are also going to see the static variable in Java. Java programming language defines a list of keywords. Here is the static keyword definition from Oracle: static is a keyword which defines a variable as a class variable. Classes maintain one copy of class ...

Read More »

Java Unit Testing with Mockito Example

In this post, we feature a comprehensive article about Java Unit Testing with Mockito Example. 1. Introduction Java unit testing is a software testing which focuses on testing methods in a class. When a class depends on other classes and/or interfaces, we can test it by using Mockito to create and configure mock objects. In this example, first, I will ...

Read More »

Java Unit Testing with JUnit Example

This is an article for Java Unit Testing with JUnit Example. 1. Introduction Java unit testing is a software testing where methods and classes are tested. JUnit is a unit testing framework for the Java programming language which provides a way to test the application as many as you want. Unit testing usually includes the following steps: define a testcreate ...

Read More »

Java Unit Testing Tutorial

This is a tutorial for Java unit testing. In this tutorial, I will create a spring boot application which includes test cases written with Junit, Mockito, and Spring test. The overall unit tests cover 90 percent of the application. Table Of Contents 1. Introduction 2. Unit Testing Frameworks 3. Technologies Used 4. Maven Project 4.1 Dependencies 4.2 Application Properties 4.3 ...

Read More »

Hashset Java Example

1. Introduction The HashSet class is a part of the Java Collection API since JDK 1.2. It extends from the AbstractSet class and implements the Set Java interface. It uses HashMap internally. Figure 1 HashSet You can also check the Java Set Example in the following video: Java Set Example – Video The HashSet class contains unique elements. It permits ...

Read More »

Java Stream Map Example

1. Introduction Java has provided Stream API to iterate and process elements in a collection with a declarative style since version 8. A stream is a sequence of objects that can be constructed via the default java.util.Collection.stream() method, static java.util.Arrays.stream() method, static java.nio.file.Files.lines() method, etc. Streams don’t change the element data. Stream API provides intermediate and terminal operations to process ...

Read More »