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 8 Functional Programming Tutorial

Java 8 supports functional programming via the lambda expression and Stream API. In this tutorial, I will demonstrate how Java 8 supports functional programming via common pre-defined functional interfaces, Collections, and Stream API. Table Of Contents 1. Introduction 2. Technologies Used 2.1 Maven Project 3. Java 8 Predefined Functional Interfaces 3.1 Function 3.2 Predicate 3.3 Supplier 3.4 Consumer 3.5 UnaryOperator ...

Read More »

Java 8 Format LocalDateTime Example

1. Introduction Java 8 Date-time API provides a java.time.LocalDateTime class which is an immutable date-time object and often is viewed as a year-month-day-hour-minute-second format. It contains a java.time.format package to handle the formatting of dates and times. This package includes three classes: DateTimeFormatter – to print and parse date-time objects. It provides common formatting constants as well as a string ...

Read More »

Java 8 Compare Dates Example

1. Introduction Java 8 added a new set of packages to provide a comprehensive date-time model. Java 8 Date-Time API is a JSR-310 implementation. There are several interfaces: ChronoLocalDate, ChronoLocalDateTime, ChronoZonedDateTime in java.time.chrono packages. They all have isBefore, isAfter, isEquals, and compareTo methods to compare two dates. Java 8 date classes: java.time.LocalDate, java.time.LocalDateTime, java.time.Instant, java.time.ZonedDateTime, java.time.chrono.JapaneseDate, java.time.chrono.MinguoDate, etc implement these ...

Read More »

Java 8 Stream Collectors groupingBy Example

1. Introduction SQL GROUP BY is a very useful aggregation function. It groups database records on certain criteria. Java 8 Stream API enables developers to process collections of data in a declarative way. Java 8 Collectors class provides a static groupingBy method: to group objects by some property and store the results in a Map instance. It has three signatures, which ...

Read More »

Java 8 TemporalAdjusters Example

1. Introduction Java 8 Date-Time API is a JSR-310 implementation. It has a new set of packages to provide a comprehensive date-time model. java.time – base package for managing dates and times java.time.chrono – handles alternative calendaring and chronology systems java.time.format – handles formatting of dates and times java.time.temporal – accesses to date and time using fields, units, and adjusters Java 8 ...

Read More »

Java 8 Check if Array Contains a Certain Value Example

1. Introduction An array is a data structure which holds a fixed number of values of a single type. In this example, I will demonstrate how to check if an array contains a certain value in three ways: Convert an array to a Collection and check with the contains method Use Arrays.binarySearch to check when the array is sorted Convert an array ...

Read More »

Java 8 Convert String to Char Array Example

1. Introduction The Java String class represents character strings. An array is a data structure which holds a fixed number of values of a single type. The char type is a primitive type which represents a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65535 inclusive). The Character class wraps thechar type as a value in an object. An object ...

Read More »

Java 8 Add Days to Current Date Example

1. Introduction Java 8 added a new set of packages to provide a comprehensive date-time model. Java 8 Date-Time API is a JSR-310 implementation. In this example, I will use classes from the java.time and java.time.format packages to demonstrate how to add days to the current date. java.time is the base package which includes a set of date-time classes: LocalDate, LocalDateTime, Instant, Period, Duration, Clock, ZonedDateTime, ...

Read More »

Java 8 Join Arrays Example

1. Introduction An Array is a data structure which holds a fixed number of objects with the same type. Joining Arrays is to combine two arrays into one. Java 8 enhances Collection by providing a new Stream interface. A stream is not a data structure, instead it is created from Collection, Array, or I/O channels. Java 8 provides a Stream interface which contains several methods ...

Read More »

Selenium Web Application Testing Example

1. Introduction In this post, we feature a comprehensive example on Selenium web application testing. A web application is a client-server computer program which the client runs in a web browser. Spring Web model-view-controller (MVC) framework provides an easier way to develop a web application. Spring boot provides auto configuration to simplify the configuration steps. Selenium is a set of software tools ...

Read More »