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

Java – Pass-by-Value II

Pass By Value Continue from the previous post. We are going to validate and verify whether this statement is true or not, which is Java is always pass-by-value. Business Objects as Arguments public class Student { private String name; public String getName() { return name; } public void setName(String name) { = name;... » read more

Java – Pass-by-Value I

How Arguments Are Passed in Java No matter reference type or primitive type of arguments, Java is always pass-by-value. Each time a method is invoked, a copy for each argument is created in the stack memory and the copy version is passed to the method. If the original variable type is primitive, then simply, a... » read more

Java – Variable Types Explained

There are 2 types of variables in Java, namely primitive & reference. Primitive Type Primitive-type variables are always stored inside the stack memory. Stack is a memory space that holds method-level variables that are short-lived in addition to references to other objects in the heap. Example of primitive type variables: Data Type Default Value (for... » read more

Java – Unary Operator Prefix and Postfix Operand Explained

Increment/Decrement Unary Operators The beauty of unary operators is that, they require only single operand to get the same result as compare to the arithmetic operators; they perform various operations such as increment(++)/decrement(–) a value by one, negating an expression, or inverting the value of a boolean. Operator Description ++ Increment operator; increments a value... » read more

Java – Storing Integer Value of Bit-Mask

In this tutorial, we will guide you how to show an integer’s 1s position on bit level. Example: 26 => {1, 3, 4} Use java.util.BitSet to store, well, a set of bits. package; import java.util.BitSet; public class Util{ public static BitSet fromInt(int num) { BitSet bs = new BitSet(); for (int k =... » read more