Java

Let’s learn functional interface in java. Functional interface in java Functional interface is one kind of an interface which has only one abstract method. Syntax: @FunctionalInterface interface interfacename { // one abstract method } NOTE: @FunctionalInterface is an annotation. This annotation is optional. Before Java 8 an interface had abstract method signature but didn’t define…

Read More Functional interface in java

Let’s learn random class in java. Random class in java An instance of Random class is used to generate a stream of pseudorandom numbers. Instances of java.util.Random are not cryptographically secure. Instances of java.util.Random are threadsafe. However, the concurrent use of the same java.util.Random instance across threads may encounter contention and consequent poor performance. Random…

Read More Random class in java

Let’s learn difference between abstract class and interface in java. Difference between abstract class and interface in java Here’s the difference between abstract class and interface. Abstract class Interface An abstract class can have protected, private, public and default as access modifiers for class members. All methods and variables in interface are always public. In…

Read More Difference between abstract class and interface in java

Let’s learn difference between class and interface in java. Difference between class and interface in java Here’s the difference between class and interface. Class Interface “Class” keyword is used to declare class. Whereas “interface” keyword is used to declare an interface. Multiple inheritance is not supported in a class whereas interface supports multiple inheritance. A…

Read More Difference between class and interface in java

Let’s learn difference between hashmap and hashset in java. Difference between HashMap and HashSet in java HashSet HashMap HashSet stores only objects. HashMap stores elements in key and value pairs. That is each element has its corresponding key which is used for retrieval during iteration. Insertion order is not preserved. objects inserted are based on…

Read More Difference between HashMap and HashSet in java

Let’s learn recursion in java. Recursion in java Recursion is a process where a method calls itself infinitely or continuously. Recursion program Recursion makes code closely packed and difficult to understand. Here’s an example on infinite recursive function. public class InfiniteRecursiveExample { static void print() { System.out.println(“helloworld”); print(); } public static void main(String[] args) {…

Read More Recursion in java