# Pascal Triangle in Java

Here you will learn about pascal triangle in java with a program example. What is Pascal’s Triangle? It is a triangular array of the binomial coefficients. It is a number pattern which starts with 1 at top and then placing numbers below it in triangular pattern. Each number is obtained by adding two numbers above it. Take below example, here 4 is obtained by adding 1 and 3 above it. Below I have shared the java program to print pascal

# How Many Ways to Create Object in Java?

How many ways to create object in Java? The answer is there are many ways but in this tutorial I am sharing the 5 ways to do this. Using new Keyword Using object cloning Using Class.forName() Using Class Loader Using Object Deserialization Below I have discussed each of these methods one by one with example.   How Many Ways to Create Object in Java? Method 1: Using new Keyword It is most common and popular method to create object in

# Convert Binary to Decimal in Java

Here you will get program to convert binary to decimal in Java. We can convert a binary number into decimal in two ways, using Integer.parseInt() method and by using your own logic. Below I have shared program for both the methods. Also Read: Convert Decimal to Binary in Java Convert Binary to Decimal in Java Method 1: Using Integer.parseInt() We can directly use parseInt() method of Integer class for binary to decimal conversion.

Output Enter a binary number: 11 Decimal

# Java Private Constructor

Here you will learn about java private constructor. What is private constructor in Java? We can make a constructor private by using private access modifier. Private constructor prevents the instantiation of class from outside. If needed we can create the instance only inside the class. Where to use Java private constructor? We can use private constructor in following two situations. 1. Singleton Design Pattern In single design pattern we have a singleton class that can have only one instance. The

# Convert Decimal to Binary in Java

Here you will get program to convert decimal to binary in Java. Below I have shared 3 different methods for java decimal to binary conversion. Also Read: Convert Binary to Decimal in Java Convert Decimal to Binary in Java 1. Integer.toString() Method We can convert a decimal number to binary using toString() method of Integer class. This method takes two arguments, first argument is the decimal number and second is the base in which we want to convert. For binary the

# Java Program for Prime Number

Here you will get java program for prime number. A number is said to be prime number if it is only divisible by 1 or itself. For example 2, 3, 5, 11, 13, etc are prime numbers. We can check a number is prime or not by following method. If all the numbers between 2 to n/2 doesn’t divide n completely then n is prime otherwise not. Java Program for Prime Number

Output enter a number: 11 prime

# Java Program for Palindrome Number

Here you will get java program for palindrome number. A number is said palindrome if its is equal to its reverse. For example, 131 is palindrome while 123 is not. Below I have shared two ways to check palindrome in java. Java Program for Palindrome Number Method 1: In this method we will reverse the number and then compare it with original number.

Output Enter a number: 121 Number is Palindrome   Method 2: In this method we will