Java Program for Matrix Addition

Here you will get java program for matrix addition. If you have ever done addition of two matrices in your maths subject then you can easily do this in java also. It can be done in following way. Read two matrices in 2D array a[][] and b[][] respectively inside loop. Now add each element of a[][] with corresponding position element of b[][] and save the result in c[][]. Finally display the 2D array c[][]. Note: The addition is possible only when

Read more

Upload File to Server Using Servlet and JSP Example

Here you will get example to upload file to server using servlet and jsp. File uploading is a very common and important feature of any website. In servlet and jsp it can be done in many ways. But in this tutorial I am sharing the two most commonly used methods. How to Upload File to Server Using Servlet and JSP? Method 1: Servlet 3.0 If you are using Servlet 3.0 version then it provides option for uploading files without using

Read more

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

Read more

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

Read more

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

Read more

Caesar Cipher in Java (Encryption and Decryption)

Here you will get program for caesar cipher in Java for encryption and decryption. Caesar Cipher is an encryption algorithm in which each alphabet present in plain text is replaced by alphabet some fixed number of positions down to it. Take below example. Plain Text: ABCD Key: 3 Cipher Text (Encrypted Message): DEFG As key is 3 so each alphabet will be replaced by an alphabet 3 places down to it. To decrypt a cipher text, the reverse of encryption process is followed.

Read more
1 2 3 10