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

Python – Zen of Python

Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren’t special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the... » 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

JavaScript – Checking against NaN

NaN stands for Not-a-Number in JavaScript. Sometimes when writing JavaScript codes, you might need to check whether a variable is a number or not. For example, you declare a variable foo and assign NaN to the variable, i.e let foo = NaN;. Then you might think checking can be done this way: let foo =... » read more