
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7442 Articles for Java

12K+ Views
In this article, we will understand how to compute the sum of diagonals of a matrix. The matrix has a row and column arrangement of its elements. The principal diagonal is a diagonal in a square matrix that goes from the upper left corner to the lower right corner.The secondary diagonal is a diagonal of a square matrix that goes from the lower left corner to the upper right corner.Below is a demonstration of the same −Suppose our input is −The input matrix: 4 5 6 7 1 7 3 4 11 12 13 14 23 24 25 50The desired ... Read More

1K+ Views
In this article, we will understand how to rotate matrix elements using Java. A matrix is a representation of the elements in rows and columns. Matrix rotation is shifting the position of each element of the matrix by 1 position towards its right or left. We will be using two approaches: one where the matrix is rotated based on user input, and another where the matrix is defined within the code. Problem Statement Write a Java program to rotate matrix elements. Below is a demonstration of the same − Input The matrix is defined as 1 2 3 4 5 6 ... Read More

12K+ Views
In this article, we will understand how to print X star pattern using Java. The pattern is formed by using multiple for-loops and print statements. The pattern forms the shape of the letter "X" by printing stars ('X') and spaces in specific positions. The user can provide a number as input, which will determine the size of the pattern. The program uses nested loops to create the required star pattern, where stars are placed at the diagonal positions of a grid. Problem Statement Write a program in Java to print X star pattern. Below is a demonstration of the same: ... Read More

1K+ Views
In this article, we will understand how to print half diamond star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The half diamond pattern : * ** *** **** ***** ****** ******* ******** ******* ****** ***** **** *** ** *AlgorithmStep 1 - START Step 2 - Declare three integer values namely i, j and my_input Step 3 - Read the required values from the user/ define the values Step 4 - We iterate through two ... Read More

5K+ Views
In this article, we will understand how to print hollow right triangle star pattern. The pattern is formed by using multiple for-loops and print statements. For the pyramid at the first line it will print one star, and at the last line it will print n number of stars. For other lines it will print exactly two stars at the start and end of the line, and there will be some blank spaces between these two starts.Below is a demonstration of the same −InputSuppose our input is −Enter the size : 8OutputThe desired output would be −The hollow pyramid triangle ... Read More

3K+ Views
In this article, we will learn to create pyramid patterns using Java. It will help us to understand how loops work. for loop while loop Java program to create pyramid patterns We are going to print the following pyramid patterns: Half Star Pyramid Inverted Half Star Pyramid Star Pyramid Inverted Star Pyramid Numeric Pyramid Pattern 1: Half Star Pyramid We will initialize the row to 5 and a loop runs from i-1 to i

6K+ Views
In this article, we will understand how to print pyramid star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The pyramid star pattern : * * * * * * * * * * * * * * * * * * * * * * * ... Read More

12K+ Views
In this article, we will understand how to print square star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the length of a side : 8OutputThe desired output would be −The square pattern : * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ... Read More

1K+ Views
In this article, we will understand how to print the Diamond Star pattern using Java. The pattern is formed by using multiple for-loops and print statements. Output Below is the demonstration of the diamond star pattern − The diamond star pattern : * *** ***** ******* ********* *********** ************* *************** ************* *********** ********* ******* ***** ... Read More

723 Views
In this article, we will understand how to print star Pascal’s triangle in Java. The Pascal’s triangle is formed by using multiple for-loops and print statements. All values outside the triangle are considered zero (0). The first row is 0 1 0 whereas only 1 acquire a space in Pascal’s triangle, 0s are invisible. The second row is acquired by adding (0+1) and (1+0). The output is sandwiched between two zeroes. The process continues till the required level is achieved. Problem Statement Write a program in Java to print star Pascal's triangle. Below is a demonstration of the same − ... Read More