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 printf() Method Example

1. Introduction In this post, we feature a comprehensive article on Java printf() Method. Java PrintStream class has provided the printf method to write a formatted string to the PrintStream object since version 5. Here are the method’s signatures: public PrintStream printf(Locale l, String format, Object... args) public PrintStream printf(String format, Object... args) l – a locale to apply during ...

Read More »

Java Interfaces Example

1. Introduction In this post, we feature a comprehensive article on Java Interfaces. Java interface is an abstract type that defines methods that classes must implement. It can contain constants, abstract method signatures, default methods along with an implementation body, static methods along with an implementation body, and nested types. Java Interface defines the “contracts” and represents the IS-A relationship. ...

Read More »

Java Binary Search Tree Example

1. Introduction A binary tree is a recursive data structure where each node can have at most two children. A binary search tree (BST) is a special type of binary tree which has the following properties: The left sub-tree of a node contains the nodes with the key’s value lesser than itself.The right sub-tree of a node contains the nodes ...

Read More »

TestNG Creating Selenium Scripts Example

1. Introduction In this post, we feature a comprehensive article on TestNG Creating Selenium Scripts. TestNG is an open-source automated testing framework for Java unit testing which is inspired by both JUnit and NUnit. It supports the following unit testing features: It provides a suite of annotations: @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod, @Test, etc.It bundles test classes with xml files.@Test attributes are ...

Read More »

Java Add Newline Character Example

1. Introduction In this post, we feature a comprehensive article on Java Add Newline Character. A new line character is a character which marks the end of a text line and the beginning of a new line. According to the ASCII table, there are two control characters which represent a new line: LF – represents “NL line feed, new line”CR ...

Read More »

Java CompletableFuture Example

1. Introduction In this post, we feature a comprehensive article on Java CompletableFuture. Asynchronous operations are common in Java applications. There are lots of challenges when dealing with asynchronous operations, such as memory leaking, race condition, callback hell, disjointed error handling, etc. Java has provided the CompletableFuture<T> class to ease these challenges since version 8. It has about 50 methods ...

Read More »

Java 12 New Features Tutorial

In this tutorial, I will demonstrate how to install JDK12 and dive into several API changes with Java examples. Table Of Contents 1. Introduction 2. Technologies Used 3. Set Up 3.1 Install Oracle Open JDK 12 3.2 Install Eclipse 4.11 3.3 Maven Project 4. Changes in String 5. Changes in NumberFormat 6. Changes in Collectors 7. Support Unicode 11 8. ...

Read More »

Java round double value to 2 decimal places Example

1. Introduction A double variable is used to hold a floating point value, such as 12.578. A decimal place is the position of a digit to the right of a decimal point. The 12.578 with 2 decimal places is represented as 12.57. Java has provided PrintStream, String.format, Formatter, NumberFormat, DecimalFormat, and BigDecimal to format and round a number based on ...

Read More »

Java Convert Byte[] array to String Example

1. Introduction A byte array is an array of bytes. A byte is binary data with 8 bits which represents an integer with values from -128 to 127. A char is a primitive data type which represents a character. The bytes translate to characters based on the character encoding scheme (such as Unicode, UTF-8, UTF-16, and UTF-32). The String class ...

Read More »

Java Generate Random Integers Example

1. Introduction Java JDK has provided the following utility classes to generate random integers over time: The java.util.Random class from version 1.0, java.util.concurrent.ThreadLocalRandom class from version 1.7, and java.util.SplittableRandom class from version 1.8. These classes provide the nextInt method to generate a random integer and ints method to generate a stream of random integers. Here are the syntax details: /** ...

Read More »