Ankith Reddy has Published 996 Articles

How to extend the size of an array in Java

Ankith Reddy

Ankith Reddy

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

569 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

242 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

Find politeness of a number in java

Ankith Reddy

Ankith Reddy

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

227 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

9K+ 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

210 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

184 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

241 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

Query in MySQL for string fields with a specific length?

Ankith Reddy

Ankith Reddy

Updated on 25-Jun-2020 11:14:27

5K+ Views

To query for string fields with a specific length, use the char_length() or length() from MySQL.SyntaxThe syntax is as follows −Case 1 − Use of char_length()This can be used when we are taking length in a number of characters.The syntax −select *from yourTableName where char_length(yourColumnName)=anySpecificLengthValue;Case 2 − Use of length()This ... Read More

Advertisements