Found 9326 Articles for Object Oriented Programming

How to Print Lower Triangular Matrix in Java?

Mr. Satyabrata
Updated on 04-May-2023 16:16:42

354 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. Triangular Matrix − A square matrix is called as a triangular matrix if all the elements above or below the diagonal of that matrix are zeros. Lower- Triangular Matrix − A square matrix is called as a Lower- Triangular Matrix if all the elements above the diagonal of that matrix are zeros. Here we have to print the lower triangular matrix. Let’s start! To show ... Read More

How to Find Sum of Matrix Elements in Java?

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

2K+ 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 sum of all the elements present inside the 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-1 Given matrix =21 22 23 24 25 26 27 28 29 Sum ... Read More

How to Display an Identity Matrix in Java?

Mr. Satyabrata
Updated on 04-May-2023 16:04:22

619 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. An identity matrix is a square matrix where all the elements of the main diagonal (i.e., the diagonal from the top-left to the bottom-right corner) are 1, and all the other elements are 0. It is denoted by the symbol "I" or "In", where "n" represents the size of the matrix. The identity matrix is important in linear algebra because it acts as the ... Read More

How to Decrement Matrix Elements by One in Java?

Mr. Satyabrata
Updated on 04-May-2023 15:48:20

85 Views

Matrices are nothing but it’s more than a collection of data elements arranged in a rectangular layout that is two-dimensional. In Java, an array with two dimensions can be considered as a matrix. As per the problem statement we have to subtract an element “1” to each matrix element. 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-1 Suppose the original matrix is {{3, 1, 2}, {2, 5, 9}, {6, 3, 10}}; After subtracting the element “1” by given matrix, the result index will ... Read More

How to convert Wrapper Objects to Primitive Types in Java?

Mr. Satyabrata
Updated on 04-May-2023 15:45:52

2K+ Views

In Java, A primitive type (i.e., int, double, float, etc.) is a basic data type that is built into the language and is not an object. Primitive types have a fixed size and can be used directly in calculations and operations. A wrapper object is nothing but an object representation of a primitive type. For example, the Integer class is a wrapper object for the int primitive type. Wrapper objects are instances of classes and have methods that can be called, while primitive types do not. However, using wrapper objects requires more memory than using primitive types, ... Read More

How to Convert String to Object in Java?

Mr. Satyabrata
Updated on 04-May-2023 15:40:30

4K+ Views

In Java, Object is a parent class of all the classes. So, we can directly assign a string to an object as each class is internally a child class of the Object class. A string is generally considered a data type and is often implemented as an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding. The object data type is also known as non-primitive or reference data type; these are not predefined ones; instead, we need to create them. Let’s deep dive into this article, to know how it ... Read More

How to Convert Int to Double in Java?

Mr. Satyabrata
Updated on 04-May-2023 15:36:46

2K+ Views

In Java, smaller datatype can be converted to bigger datatype. Here, we will see how to convert int datatype to double datatype. The int data type is a 32-bit signed two's complement integer. Its value-range lies between - 2, 147, 483, 648 (-2^31) to 2, 147, 483, 647 (2^31 -1). The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification. Let’s deep dive into this article, to know how it ... Read More

How to Convert Date to Timestamp in Java?

Mr. Satyabrata
Updated on 04-May-2023 15:32:29

4K+ Views

In Java, Date can be converted Timestamp by using Timestamp class. Timestamp class is present in sql package. Date only store date value whereas timestamp stores both date and time value. The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. 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-1 Suppose the input date is written on 05/01/2023. Then corresponding Timestamp is “2023-01-05 20:37:54.832”. Instance-2 ... Read More

How to Check if Two Given Circles Touch or Intersect in Java?

Mr. Satyabrata
Updated on 04-May-2023 15:56:19

1K+ 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 if two given circles touch or intersect each other. We will be given the two circles with center 1 i.e (x1, y1) and center 2 i.e (x2, y2) and radius R1 and R2. We need to check if the given circle collides with the other circle or not and hence five possible situation arises as mentioned below − Circle 2 lie inside circle 1 Circle 1 ... Read More

How to Check if the Matrix is Diagonal Matrix in Java?

Mr. Satyabrata
Updated on 04-May-2023 15:55:59

568 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. A matrix having non-zero elements only in the main diagonal (running from the upper left to the lower right) is called as diagonal matrix. As per the problem statement we have to a matrix and we have to check whether that given matrix is a diagonal matrix or not. Let’s deep dive into this article, to know how it can be done by using Java ... Read More

Advertisements