Ankith Reddy has Published 1070 Articles

How to extend the size of an array in Java

Ankith Reddy

Ankith Reddy

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

411 Views

An array has a fixed number of values and its size is defined when it is created. Therefore, the size of the array cannot be changed later. To solve this problem, an ArrayList should be used as it implements a resizable array using the List interface.A program that demonstrates ArrayList ... Read More

Nth Catalan numbers in java

Ankith Reddy

Ankith Reddy

Updated on 25-Jun-2020 12:32:38

147 Views

The nth Catalan number in terms of binomial coefficients is calculated by the formula(n + k )/k where k varies from 2 to n and n ≥ 0. i.e.Cn = (2n)!/((n+1)!n!)Programpublic class NthCatalanNumber {    public static long fact(int i) {       if(i

Dump Multi-Dimensional arrays in Java

Ankith Reddy

Ankith Reddy

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

225 Views

A multi-dimensional array can be easily printed by using the method java.util.Arrays.deepToString() in Java. This method converts the multi-dimensional array to string and prints the array contents enclosed in square brackets.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo {    public static void ... Read More

Find politeness of a number in java

Ankith Reddy

Ankith Reddy

Updated on 25-Jun-2020 12:17:45

170 Views

The numbers which can be expressed as the sum of positive consecutive integers are known as polite numbers.Ex: 5 = 2+3The number of ways a number can be expressed as the sum of positive integers will be the Politeness of that number.Ex: 9 = 4+5 || 2+3+4AlgorithmGet the prime factors ... Read More

Find all divisors of a natural number in java

Ankith Reddy

Ankith Reddy

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

6K+ Views

Following is the Java program which prints all the divisors of a given number.Programimport java.util.Scanner; public class DivisorsOfNaturalNumber {    public static void main(String args[]) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter required number :");       int num = sc.nextInt();             for(int i = 1; i

Initialize an Array with Reflection Utilities in Java

Ankith Reddy

Ankith Reddy

Updated on 25-Jun-2020 12:12:24

108 Views

An array can be initialized using the method java.util.Arrays.fill() that is a utility method provided in the java.util.Arrays class. This method assigns the required value to all the elements in the array or to all the elements in the specified range.A program that demonstrates this is given as follows −Example Live ... Read More

GCD of an array of numbers in java

Ankith Reddy

Ankith Reddy

Updated on 25-Jun-2020 12:00:32

2K+ Views

ProgramFollowing is the example to calculate the GCD of the numbers of an array.Live Demopublic class GCDOfArrayofNumbers{    public static int gcd(int a, int b){       int res = 0;       while (b > 0){          int temp = b;       ... Read More

Usage of calc() CSS function

Ankith Reddy

Ankith Reddy

Updated on 25-Jun-2020 11:41:50

145 Views

Get the values of properties in CSS using the calc() property. You can try to run the following code to implement the calc() function in CSSExampleLive Demo                    #demo {             position: absolute;             width: calc(100% - 100px);             background-color: blue;             text-align: center;          }                     Heading One       This is it!    

Perform Animation on border-bottom-width CSS property

Ankith Reddy

Ankith Reddy

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

108 Views

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

How does MySQL CASE work?

Ankith Reddy

Ankith Reddy

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

142 Views

The MySQL CASE works like a switch statement. The syntax of CASE is as follows −Case 1 − Compare StatementCase when anyCompareStatement then value1 when anyCompareStatement then value2 . . N else anyValue end as anyVariableName;Case 2 − ConditionsThe second syntax can be used when you are selecting only one ... Read More

Advertisements