Home » Author Archives: 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 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 »

Linear Search Java Example

1. Introduction Linear search is a computer algorithm which finds an element from an array sequentially. The time complexity is O(n) in the worst case – meaning the element is the last element of the array or not in the array. The time complexity is O(1) in the best case – meaning the element is the first element of the ...

Read More »

Multiple Inheritance Java Example

1. Introduction Multiple inheritance means that a class inherits fields and methods from more than one parent. Java class does not support multiple inheritance as it cannot have more than one parent. Java supports multiple inheritance via interface because an interface can have more than one parent. The “diamond problem” is an ambiguity that arises when two classes B and ...

Read More »

What is a Field in Java

1. Introduction Java is an object-oriented programming language which uses “object” concept to group data and methods in a class. A variable defined in a class is called a field. A field is declared by specifying its type and name. In this example, I will demonstrate: Declare a field for the primitive data type, object, and collectionAdd static, final, transient, ...

Read More »

Pi in Java Example

In this post, we feature a comprehensive article about Pi in Java. 1. Introduction PI is a mathematics number defined as the circumference of any circle divided by its diameter. Java has provided the java.lang.Math class since version 1. It includes a static constant PI with value of 3.141592653589793. /*the double value that is closer than any other to pi, ...

Read More »

isDigit Java Example

1. Introduction Java provides a java.lang.Character class to wrap a value of the primitive type char in an object. It has provided several methods for determining a character’s category, such as lowercase letter, digit, etc since version 5. Here are the isDigit method’s signatures: //Determines if the specified character is a digit. static boolean isDigit​(char ch) //Determines if the specified character (Unicode ...

Read More »

Breadth First Search Java Example

1. Introduction Breadth First Search (BFS) is a traversing or searching algorithm for a tree or graph data structure. BFS starts at the tree root, and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level. A tree is a nonlinear data structure which includes a root and ...

Read More »

Selection Sort Java Example

1. Introduction Selection sort Java ‘s simple algorithm, can divide the array into sorted and unsorted parts. Initially, the sorted part is empty; the unsorted part is the entire array. It starts by finding the smallest element from the unsorted part and swaps it with the left-most element of the unsorted part. Each finding reduces the unsorted part by one. ...

Read More »

Big O Notation Java Example

In this post, we feature a comprehensive Big O Notation Java Example. 1. Introduction Asymptotic notations are used to analyze an algorithm’s running time by identifying its behavior as the input size for the algorithm increases. There are six symbols used to characterize the relative growth rates of functions: SymbolSummary f = Θ(g) f grows at the same rate as ...

Read More »

String equalsIgnoreCase() Java Example

In this post, we feature a comprehensive article about the equalsignorecase Java ‘s String Method. 1. Introduction Java String class has provided the equalsIgnoreCase method to compare this String to another String by ignoring case since version 1. Here is the method’s signature: boolean equalsIgnoreCase​(String anotherString) The String class inherits the equals method from the Object class. It returns true if and only if the argument ...

Read More »