Home » Core Java (page 10)

Core Java

Java String trim() method with Example

1. Introduction The java.lang.String class represents character strings. It provides a trim() method since version 1.4 to return a new string object whose value is the copy of the original string without any leading or trailing white-space. Note: a white-space is when the ASCII code of the character is less than or equal to the space character, which is \u0020. ...

Read More »

Java Interpreter Design Pattern Example

1. Introduction to Java Interpreter Design Pattern The interpreter design pattern is one of the behavioral design patterns that indicate how the words can be evaluated in a language. For an example, we will take one of our day to day used application Google Translator. Google Translator is an Interpreter design pattern example, in which the input can be read ...

Read More »

Java Command Design Pattern Example

1. Introduction to Java Command Design Pattern In this post, we will discuss the concept java Command design pattern. The command design pattern is one of the behavioral design pattern in object oriented programming where the object is used to hide the information that is necessary to carry out an action or to activate events later. This data involves the ...

Read More »

Java Strategy Design Pattern Example

1. Introduction to Java Strategy Design Pattern In this article, we will elaborate java Strategy design pattern in detail which is one of the important behavioral design pattern. The Strategy design pattern is also referred to as a policy pattern which allows the selection of an algorithm at runtime as needed. We define several algorithms or strategies in the java strategy ...

Read More »

Java State Design Pattern Example

1. Introduction to Java State Design Pattern In this article, we will introduce java state design pattern in detail. The java State design pattern is one of the behavioural design pattern. When an object changes its behavior based on its internal state, the State design pattern is used. So, we create objects in a State design pattern that represent different ...

Read More »

Java Template Design Pattern Example

1. Introduction to Java Template Design Pattern In this post, we will discuss and elobarate the java template design pattern in detail. Java Template design pattern is one of the important behavioral design pattern. Template design pattern describes algorithm steps and can provide default implementations common to most or all of the subclasses. Let’s get an example to understand and ...

Read More »

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 ...

Read More »

Java Memento Design Pattern Example

1. Introduction to Java Memento Design Pattern In this article, we will discuss about one of the java design pattern – Java Memento Design Pattern. Memento design pattern is one of behavioural design patterns. Memento design pattern is mostly used when we like to save an object’s condition so that we can restore it later. Let us look deeply into ...

Read More »

Java Prototype Design Pattern Example

1. Introduction to Java Prototype Design Pattern In this article, we would be discussing in depth the Java Prototype Design pattern. Java Prototype Design pattern is a creational design pattern that provides a way of prototyping objects of similar nature. In Java, the creation of objects is an expensive job in terms of the processing power being consumed. In case ...

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 »