Found 9326 Articles for Object Oriented Programming

Find Largest & Smallest Element in Each Column of a Matrix in Java?

Mr. Satyabrata
Updated on 04-May-2023 13:54:27

805 Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. The matrix in java is nothing but a multi-dimensional array which represents multiple rows and columns. Here we have given a matrix which contains set of elements and as per the problem statement we have to find out the largest and smallest element in each column of that matrix. Let’s deep dive into this article, to know how it can be done by using Java programming language. To show you some instances Instance-1Given matrix = 21 22 23 24 25 26 27 28 29 ... Read More

Find Largest & Smallest Element in Primary and Secondary Diagonal of a Matrix in Java

Mr. Satyabrata
Updated on 04-May-2023 13:50:28

335 Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. The matrix in java is nothing but a multi-dimensional array which represents multiple rows and columns. Here we have given a matrix which contains set of elements and as per the problem statement we have to find largest and smallest element in primary and secondary diagonal of a matrix. Let’s deep dive into this article, to know how it can be done by using Java programming language. To show you some instances Instance-1Given matrix = 21 22 23 24 25 26 27 28 29 ... Read More

Check if a Point Exists in Circle Sector in Java

Mr. Satyabrata
Updated on 04-May-2023 13:42:45

225 Views

A circle is a closed shape formed by tracing a point that moves in a plane such that its distance from a given point is constant. In this article we will check how to form the equation of circle from given radius and centre. We will be given a circle with point i.e (x, y), radius r and centre i.e (x1, y1). We need to form the equation of circle from given radius and centre. The equation of the circle is given by formula − $$\mathrm{(x\:-\:x1)^2\:+\:(y\:-\:y1)^2\:=\:r^2}$$ Where, (x, y) is a point. (x1, y1) is centre. And r ... Read More

Java Program for Decimal to Binary Conversion

Shriansh Kumar
Updated on 02-May-2023 18:58:58

3K+ Views

The number system is of four types: Binary, Octal, Decimal and Hexadecimal with base value 2, 8, 10 and 16 respectively. The base value depends on the number of digits contained by number system. For example, hexadecimal number system contains 16 digits i.e. 0 to 9 and A to F. Hence, its base is 16. In this article, we will discuss the binary and decimal number systems. Also, we will make java programs to convert decimal to binary numbers. Binary and Decimal number system Binary number system Binary number system works in the form of 0s and 1s. Since ... Read More

Java Program for Reversal algorithm for right rotation of an array

Shriansh Kumar
Updated on 02-May-2023 19:05:09

133 Views

Array is a linear data structure that is used to store group of elements with similar datatypes. It stores data in a sequential manner. Once we create an array we can’t change its size i.e. it can store fixed number of elements. This article will help you to understand the Reversal Algorithm and also, we will make a java program in which we create an array and perform right rotation by applying reversal algorithm. Right Rotation of an Array Let’s understand the term right rotation in context of an array. In right rotation of an array, we simply shift ... Read More

Java public static void main(String[] args)

Shriansh Kumar
Updated on 21-Jun-2024 11:45:02

5K+ Views

The java programs start execution when JVM calls the main() method. Java application begin from this method. Without main method, a java file will compile successfully because at compile time, compiler doesn’t check for main method but at run time JVM checks whether the main() method is available or not. Therefore, we will get an exception at run time. In this article, we will understand why we follow the convention “public static void main(String[] args).” Syntax public class class_name { // This line must be written as it is public static void main(String[] args) ... Read More

Java program for Hexadecimal to Decimal Conversion

Shriansh Kumar
Updated on 02-May-2023 18:55:51

601 Views

The number system is of four types: Binary, Octal, Decimal and Hexadecimal with base value 2, 8, 10 and 16 respectively. The base value depends on the number of digits contained by number system. For example, binary number system contains only two digits 0 and 1. Hence, its base is 2. In this article, we will discuss the hexadecimal and decimal number systems. Also, we will make java programs to convert hexadecimal to decimal numbers. Hexadecimal and Decimal number system Hexadecimal number system It represents the numbers from 0 to 9 and A to F. There is a total of ... Read More

Java Program for Int to Char Conversion

Shriansh Kumar
Updated on 02-May-2023 18:53:56

164 Views

Java has eight primitive datatypes byte, short, int, long, char, float, double, and boolean. The int is 32-bit signed datatype used to store whole numbers. Its range is from –2, 147, 483, 648 to 2, 147, 483, 647. The char holds 16-bit unsigned Unicode characters. In this article, we will discuss few approaches for int to char conversion − By adding ‘0’ By using forDigit() method By using typecasting Example 1 The following example illustrates how to declare and initialize int variable. int num1 = 24; int is the keyword used to declare int variable, num1 ... Read More

Java Program for Rotate the Matrix Right by K times

Shriansh Kumar
Updated on 02-May-2023 18:52:46

375 Views

Array is a linear data structure that is used to store group of elements with similar datatypes. It stores data in a sequential manner. When we create an array of two dimensions, i.e., rows and columns, we call it matrix. In this article, we will create a matrix of MxN and try to rotate it right by K times. Here, ‘M’ and ‘N’ are the size of the row and column respectively. ‘K’ is the number of times we want to rotate the matrix. Matrix Rotation to Right Let’s understand what is matrix rotation with the following visual representation − ... Read More

Java Nested Loops with Examples

Shriansh Kumar
Updated on 02-May-2023 18:47:28

980 Views

Loops in java are called as control statements because they decide the flow of execution of a program based on some condition. Java allows the nesting of loops, when we put a loop within another loop then we call it a nested loop. Nested loops are very useful when we need to iterate through a matrix array and when we need to do any pattern-based questions. In this article, we are going to learn about java nested loops with examples. Nested Loops We can create nested loops for the following control statements − For loop If else While ... Read More

Advertisements