Top Posts in Python
numpy.square() in Python
Python numpy.square() function returns a new array with the element value as the square of the source array elements. The source array remains unchanged. Python numpy.square() Examples It’s a utility function to quickly get the….
numpy.zeros() in Python
Python numpy.zeros() function returns a new array of given shape and type, where the element’s value as 0. numpy.zeros() function arguments The numpy.zeros() function syntax is: zeros(shape, dtype=None, order=’C’) The shape is an int or….
Python Remove Duplicates from a List
There are many ways to remove duplicates from a Python List. Using a temporary List and Looping Using set() built-in method Using Dictionary Keys List count() function List Comprehension Removing Duplicates from a List Python….
LRU Cache Implementation in Java
What is LRU Cache? LRU Cache stands for Least Recently Used Cache. The size of the cache is fixed and it supports get() and put() operations. When the cache is full, the put() operation removes….
Java System.arraycopy() Method Examples
Java System.arraycopy() is a native static method to copy elements from the source array to the destination array. System.arraycopy() Method Arguments The System.arraycopy() method signature is: public static native void arraycopy(Object src, int srcPos, Object….
How to Shuffle an Array in Java
There are two ways to shuffle an array in Java. Collections.shuffle() Method Random Class 1. Shuffle Array Elements using Collections Class We can create a list from the array and then use the Collections class….
Java Collectors Class – 18 Examples
Java Collectors is a utility class that provides many useful implementations of the Collector interface. The Collector implementation is used with the Stream collect() method. This class was introduced in Java 8 along with Stream….
Java Method Reference Types and Examples
Java Method Reference was introduced in Java 8, along with lambda expressions. The method reference is a shortcut way to create lambda expressions when it just calls a method. What is Java Method Reference? The….
Java Stream collect() Method Examples
Java Stream collect() performs a mutable reduction operation on the elements of the stream. This is a terminal operation. What is Mutable Reduction Operation? A mutable reduction operation process the stream elements and then accumulate….
How to Check if Java Array Contains a Value?
How to Check if Java Array Contains a Value? There are many ways to check if a Java array contains a specific value. Simple iteration using for loop List contains() method Stream anyMatch() method Arrays….