Category Archives: Java Array

How to Copy One Array to Another in Java

Here you will learn how to copy one array to another in Java. There are mainly four different ways to copy all elements of one array into another array in Java. 1. Manually 2. Arrays.copyOf() 3. System.arraycopy() 4. Object.clone() Lets discuss each of them in brief. How to Copy One Array to Another in Java… Read More »

Convert Array to ArrayList in Java

In this tutorial you will learn how to convert array to arraylist in Java. There are mainly two ways to convert a Java array to arraylist. Using Arrays.asList() method Using Collections.addAll() method Below I have shared an example of each of these methods. In these examples we are converting string array to arraylist. Also Read: Convert… Read More »

Radix Sort Java Program and Algorithm

In this tutorial we shall discuss about a topic that emerges as often as possible in programming: the revision of things into descending order or ascending order. Envision how hard it would be to utilize a dictionary on the off chance that its words were not ordered! We always know that, the order in which… Read More »

Program for Binary Search in Java

Binary search in Java is a divide and conquer technique used to search an element in an array. The array is assumed to be sorted in ascending order. Below I have shared the program for binary search in Java. You can ask your doubts if you find difficulty to understand the program. Java Program for… Read More »

2D Array in Java

In this tutorial you will learn about 2D array in Java. If you don’t know about what is array then I would recommend you to read the previous tutorial: Array in Java (1D) 2D Array in Java Array is a collection of similar type of elements. Array can be of any dimension but generally we… Read More »

Anonymous Array in Java

An array without name is known as anonymous array in java.  As the array do not have any name so it can be used only once.  Anonymous array is passed as an argument of method.  Anonymous array is created and initialized in the same line. How to Create Anonymous Array in Java? A sample program… Read More »

Array in Java (1D)

In this tutorial I will talk about one dimensional array in java. In the next tutorial we will learn about multidimensional array. Array in Java Array is the collection of similar type of data having contiguous memory location.  Due to contiguous memory location the performance becomes fast.  The biggest disadvantage of array is, we can’t… Read More »

Java Program to Find Transpose of Matrix

Transpose of a matrix is a new matrix whose columns are the rows of original matrix and rows are the columns of original matrix. Take below example for transpose of matrix of order 3×3. Image Source Below I have shared java program that will find transpose of matrix of any order. If you find any… Read More »

Bubble Sort Java Program

Bubble sort in java is the simplest sorting technique. In bubble sort algorithm each element is compared to next adjacent element, if the next element is smaller, then it will be swapped by previous element. Although this technique is simple but it is too slow as compared to other sorting techniques. Below I have shared… Read More »

Java Program for Multiplication of two Matrices

import java.util.Scanner; //import Scanner class in our program class demo { public static void main(String…s) { int i,j,m,n,p,q,k; Scanner sc=new Scanner(; //used to read from keyboard System.out.print(“Enter number of rows and columns of first matrix:”); m=sc.nextInt(); n=sc.nextInt(); System.out.print(“Enter number of rows and columns of second matrix:”); p=sc.nextInt(); q=sc.nextInt(); if(n!=p) System.out.print(“nSorry multiplication can’t be done!!”); else… Read More »