#
java programs Archive

In this program, we will print prime numbers from 1 to 100 in java. A prime number is a number which has only two divisors 1 and itself. To check if the number is prime …

In this post, we will see how to implement distance formula between two points in java. Formula to find distance between two points ( x1, y1) and (x2 , y2) is d= sqrt( (x2-x1)^2+ (y2 …

In this post, we will see how to convert decimal to binary in java. There are lot of ways to convert decimal to binary in java.Let’s explore them one by one. Using Integer.toBinaryString() method You …

In this post, we will see how to calculate total surface area of Hemisphere in java. Hemisphere is exactly half of sphere. There can be many practical examples of Hemisphere. You can divide earth into …

In this post, we will see how to calculate total surface area of Cylinder in java. Formula of calculating total surface area of Cylinder is: Surface area of Cylinder = 2 *Π * r * …

In this post, we will see how to program FizzBuzz in java. Fizzbuzz is a fun game played generally by school children.It is simple game in which when your turn comes, you need to say …

In this post, we will see how to print the following pyramid pattern. Problem Input : n = 4 Output : 1 3*2 4*5*6 10*9*8*7Input : n = 5 Output : 1 3*2 4*5*6 10*9*8*7 …

In this tutorial, we will see Find Longest Substring Without Repeating Characters in java. Problem We need to find Longest Substring Without Repeating Characters Solution Brute force solution Find all the substring and check the …

In this tutorial, we will see java program to find permutation and combination. Permutation is represented as nPr and Combination is represented as nCr.It is simple program which involves factorial of the numbers. Here is …

In this post, we will see how to reverse a number in java. Here is simple program to reverse a number. Output: Enter a Number : 4567 Reverse of the number : 7654 Let’s …