Found 9344 Articles for Object Oriented Programming

How to Read a File into an ArrayList in Java?

Mr. Satyabrata
Updated on 17-Aug-2023 17:45:16

1K+ Views

In Java, an ArrayList is a resizable array, which is implemented as part of the Java Collections Framework. It is a dynamic data structure that can hold any type of objects, including primitive types such as integers and characters. As per the problem statement we have to read a file into an ArrayList. First and foremost we will take the path of the file as input and then we will apply different method to read the file. Let's start! For instance Suppose the input file is “myfile.txt”. After reading the content of the file, the result ... Read More

How to Convert Timestamp to Date in Java?

Mr. Satyabrata
Updated on 17-Aug-2023 17:38:41

6K+ Views

Java, Timestamp can be converted Date by using Date class. Date class is present in java.util package. The constructor of the Date class receives a long value as an argument. Since the constructor of the Date class requires a long value, we need to convert the Timestamp object into a long value using the getTime() method of the TimeStamp class. Let's deep dive into this article, to know how it can be done by using Java programming language. To show you with instance Suppose the timestamp is 06/01/2023. Then corresponding Date is “Fri Jan 06 ... Read More

How to Convert Char to Int in Java?

Mr. Satyabrata
Updated on 17-Aug-2023 17:35:59

332 Views

In Java, smaller datatype can be converted to bigger datatype. Here, we will see how to convert char datatype to int datatype. The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65, 535 inclusive). The int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. Let's deep dive into this article, to know how it can be done by using Java programming language. For instance Suppose the given ... Read More

Create a Matrix and Fill Primary Diagonal with 1 and Secondary Diagonal with 2

Mr. Satyabrata
Updated on 17-Aug-2023 17:33:03

141 Views

In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to Create a Matrix and Fill Primary Diagonal with 1 and Secondary Diagonal with 0. Let's start! For instance Suppose we have 4*4 matrix i.e. 4 rows and 4 columns. After performing the operation on matrix, the result will be: Enter the size of the matrix: ... Read More

Java Program to Create a Matrix and Fill it With Prime Numbers

Mr. Satyabrata
Updated on 17-Aug-2023 17:29:42

298 Views

In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to create an empty matrix and fill that matrix with the prime numbers starting from the smallest prime number i.e. 2. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In simpler terms, a prime number is a ... Read More

Java Program to Create a Matrix and Fill it With Palindrome Number

Mr. Satyabrata
Updated on 17-Aug-2023 17:27:34

122 Views

In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to Create a Matrix and Fill it with Palindrome Number. Let's start! For instance Suppose we have 4*5 matrix: After performing the operation on matrix, the result will be: Enter the number of rows: 4 Enter the number of columns: 5 Matrix with Palindrome ... Read More

Java Program to Create a Matrix and Fill it With Armstrong Number

Mr. Satyabrata
Updated on 17-Aug-2023 17:25:59

58 Views

In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to Create a Matrix and Fill it with Armstrong Number. Let's start! For instance Suppose we have 4*3 matrix: After performing the operation on matrix, the result will be: Enter the number of rows: 4 Enter the number of columns: 3 Armstrong Matrix: ... Read More

Java Program for Arithmetic Operations Between BigDecimal and Primitive Data Types

Mr. Satyabrata
Updated on 17-Aug-2023 17:24:04

100 Views

BigDecimal is a class in Java's java.math package that provides arbitrary-precision decimal arithmetic. It allows precise decimal calculations without the loss of precision that can occur with floating-point arithmetic. BigDecimal objects are immutable, so any arithmetic operation on them creates a new object with the result of the operation. Primitive data types in Java are the basic building blocks of data in the language. They include int, double, Boolean, char, and others, and represent simple values like integers, floating-point numbers, and boolean values. They are stored directly in memory and are not objects, so they have lower memory overhead ... Read More

Find Difference Between Sum of All Rows and All Columns in Java

Mr. Satyabrata
Updated on 17-Aug-2023 17:21:36

66 Views

In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to add sum of all individual rows and columns. Then we need to perform the difference between these added rows and columns and display the result. Let's start! For instance Suppose the original matrix is: {4, 2, 1}, {3, 5, 6}, {8, 9, 7} After performing ... Read More

Get Interior & Exterior Angle of Regular Polygon When Numbers of Sides of Polygon is Given in Java

Mr. Satyabrata
Updated on 17-Aug-2023 17:17:31

66 Views

A polygon is a 2-dimensional closed shape that has at least 3 sides. Depending on the number of sides, relationships of the sides and angles, and other characteristics, polygons can be classified under different names like triangles, squares, and quadrilaterals. An interior angle of a polygon is an angle formed inside the two adjacent sides of a polygon. Exterior angle is defined as the angle formed between a side of triangle and an adjacent side extending outward. In this article, we will find interior and exterior angle of regular polygon when numbers of sides of polygon is ... Read More

Previous 1 ... 6 7 8 9 10 ... 935 Next
Advertisements