George John has Published 1167 Articles

Sort subset of array elements in Java

George John

George John

Updated on 25-Jun-2020 12:41:05

4K+ Views

The java.util.Arrays.sort() method can be used to sort a subset of the array elements in Java. This method has three arguments i.e. the array to be sorted, the index of the first element of the subset (included in the sorted elements) and the index of the last element of the ... Read More

Java Program to implement Binary Search on an array

George John

George John

Updated on 25-Jun-2020 12:34:59

305 Views

Binary search can be implemented on an array by using the method java.util.Arrays.binarySearch(). This method returns the index of the required element if it is available in the array, otherwise it returns (- (insertion point) - 1) where the insertion point is the position at which the element would be ... Read More

Modular Exponentiation (Power in Modular Arithmetic) in java

George John

George John

Updated on 25-Jun-2020 12:34:08

690 Views

The java.math.BigInteger.modPow(BigInteger exponent, BigInteger m) returns a BigInteger whose value is (thisexponent mod m). Unlike pow, this method permits negative exponents. You can calculate the modular Exponentiation using this method.ProgramLive Demoimport java.math.*; public class BigIntegerDemo {    public static void main(String[] args) {       // create 3 ... Read More

k-th prime factor of a given number in java

George John

George John

Updated on 25-Jun-2020 12:18:39

293 Views

Following is the Java program which prints the kth prime factor of a number n, when k and n are given.Programimport java.util.Scanner; public class KthPrimeFactor {    public static void main(String args[]) {       int number, k, factor = 0;       Scanner sc = new ... Read More

Compare two-byte arrays in a single line in Java

George John

George John

Updated on 25-Jun-2020 12:16:20

105 Views

Two byte arrays can be compared in Java using the java.util.Arrays.equals() method. This method returns true if the arrays are equal and false otherwise. The two arrays are equal if they contain the same number of elements in the same order. A program that compares two byte arrays using the ... Read More

Create new instance of an Array with Java Reflection Method

George John

George John

Updated on 25-Jun-2020 12:11:22

370 Views

A new instance of an Array can be created using the java.lang.reflect.Array.newInstance() method. This method basically creates a new array with the required component type as well as length.A program that demonstrates the creation of an array using the Array.newInstance() method is given as follows −Example Live Demoimport java.lang.reflect.Array; public class ... Read More

LCM of an array of numbers in Java

George John

George John

Updated on 25-Jun-2020 11:59:39

3K+ Views

L.C.M. or Least Common Multiple of two values, is the smallest positive value which the multiple of both values.For example multiples of 3 and 4 are:3 → 3, 6, 9, 12, 15 ...4 → 4, 8, 12, 16, 20 ...The smallest multiple of both is 12, hence the LCM of ... Read More

Perform Animation on CSS color property

George John

George John

Updated on 25-Jun-2020 11:53:20

91 Views

To implement animation on the color property with CSS, you can try to run the following codeExampleLive Demo                    div {             width: 200px;             height: 300px;       ... Read More

Set bottom-right corner border with CSS

George John

George John

Updated on 25-Jun-2020 11:40:32

214 Views

Use border-bottom-right-radius property for setting the border of bottom right corner. You can try to run the following code to implement border-bottom-right-radius propertyExampleLive Demo                    #rcorner {             border-radius: 25px;             border-bottom-right-radius: 90px;             background: #F5CBA7;             padding: 20px;             width: 400px;             height: 300px;          }                     Rounded border bottom corner!    

Perform Animation on background-position property with CSS

George John

George John

Updated on 25-Jun-2020 11:30:34

313 Views

Use the @keyframes to animate the background position. To implement animation on background-position property with CSS, you can try to run the following codeExampleLive Demo                    div {             width: 500px;         ... Read More

Advertisements