Kotlin – Use EnumSet For RBAC

Enumset is a powerful collection in Java to replace bit fields. This article will explains how to use EnumSet to create a RBAC (Role-Based Access Control). Now, let’s see how we can use EnumSet to create a RBAC. Inside the setup method, a series of roles with specific access right in a given system has been defined... » read more

Java – Why you should use Optional

To Overcome NullPointerException The Java 8’s Optional is meant for alleviating the occurrence of NullPointerException. NullPointerException is the result of Null References, Null Reference is also known as The Billion Dollar Mistake. The Billion Dollar mistake was coined by a British computer scientist, Sir Charles Antony Richard Hoare. Null pointers are the single biggest source... » read more

Java – What are Default Methods II

Prior to Java 8, Java interfaces cannot be implemented. Because of a class can implement more than 1 interface, and imagine in the event of there is same signature in different interfaces which the class is implementing, then in this case, the class might be confused to picking which one, cause in the past prior to... » read more

Java – How to Handle NullPointerException Effectively

NullPointerException is a common exception in Java-based applications. It is also known as Billion-Dollar mistake. NullPointerException is a sub-class of RuntimeException. A RuntimeException is an unchecked exception, it does not force you to use catch block to handle it. This article going to explain some approaches to handle NullPointerException effectively. Why NullPointerException occur in your... » read more

Java – What are Default Methods I

Java 8 brought a new capability known as default methods into Java interface. This articles guides you how to get the benefit from default methods in interface. Why Default Methods in Interfaces Are Needed Imagine in a situation where if one or more methods are added to the interface, then classes which implemented those interfaces... » read more

Java – Use Annotation to create Custom Constraint

Imagine, given a situation where you want to check if a required String field whether has emptied value or not. The simplest way is to use if keyword to check whether a given field which its type is String whether is emptied or null. if (("").equals(userModel.getFirstName())){ ...... } In addition to the above-mentioned method, one... » read more

Java – Arbitrary Number of Arguments – the 3 dots

In some Java codes, you might come across, 3 dots like this: It is known as Varargs. foo(String... values) With varargs, a method, function or even constructor can be passed in an arbitrary number of arguments. Varargs are useful, when developers are not sure how many of a particular type of argument will be passed... » read more

Java – What is Functional Interface

To create a functional interface You may come across codes like this ()->{ System.out.println("Hello World"); }, a bracket first then follow by an arrow, if you have ever written JavaScript before, it is known as arrow function in JavaScript. In Java land this is known as functional interface. To create a functional interface, all you... » read more