Found 9321 Articles for Object Oriented Programming

Program to Convert Byte Array to Writer in Java

Shriansh Kumar
Updated on 15-May-2023 16:45:00

212 Views

Byte Array can be said as the combination of byte and array. Byte is the smallest integer type and Array is a linear data structure that is used to store groups of elements of similar datatypes. This article will discuss a program to convert Byte Array to Writer in Java. Let’s understand the term Byte Array and Writer first. Byte Array and Writer Class Byte Array It is a type of array that stores a sequence of data of byte datatype. We will use the ‘getBytes()’ method to convert specified strings into sequences of characters and store them in a ... Read More

Rounding off errors in Java

Shriansh Kumar
Updated on 15-May-2023 16:42:51

610 Views

While writing codes we all do various mistakes that lead us to errors like overflow errors and syntax errors. Rounding-off error is one of the common errors that may result in a wrong solution for a given mathematical problem. Generally, this error occurs when we work with floating point numbers. In this article, we will explore the reason for this problem and try to find a way to get rid of this kind of error. Rounding off Errors Floating Point Types They are also known as real numbers and are used when the calculation requires fractional values. It represents numbers ... Read More

Rules For Variable Declaration in Java

Shriansh Kumar
Updated on 12-May-2023 17:52:12

851 Views

In any programming language, variables serve as a container that is used to store values. Before actually using a variable we need to declare it first. We can’t give any random names or symbols to it, although Java provides almost all the letters and symbols available for human and machine use. We will explore the naming conventions and set of rules for variable declaration in Java through this article. Variable Declaration in Java When it comes to declaring a variable, we need to define its type first, then name of the variable and an optional value. We can declare ... Read More

Student Grade Calculator using Java Swing

Shriansh Kumar
Updated on 12-May-2023 17:47:24

1K+ Views

Swing is a framework of Java that is used to develop window based applications. It provides a rich variety of GUI (Graphical User Interface) components that are lightweight and platform independent. Some of the classes of GUI components are JLable, JButton, JFrame, JCheckBox and so forth. In this article, we will build a simple student grade calculator using the components of Java Swing. Steps to create Student Grade Calculator using Java Swing To develop this application follow these steps − Step 1 Open your Netbeans IDE and create a new Java Application through the following path − File -> ... Read More

Simple Bill Splitter Application using Java Servlets

Shriansh Kumar
Updated on 12-May-2023 17:45:25

245 Views

Servlets are small java modules that are used on server side of a web connection to enhance the functionality of web server. All the methods and classes for creating a servlet are available in ‘javax.servlet’ and ‘javax.servlet.http’ packages. Hence, it is important to import them into your program before working with the servlet. In this article, we will develop a simple bill splitter application using Java Servlets. Before starting, make sure you have installed the NetBeans IDE and Apache Tomcat server. Steps to build Simple Bill Splitter To develop this application follow these steps − Step 1 Open your ... Read More

Separators in Java

Shriansh Kumar
Updated on 12-May-2023 17:41:53

2K+ Views

Separators are one of the building blocks of a Java program that helps us to differentiate the regions of the block of code and arrange groups of codes or statements. They help us in defining scopes of particular variables and methods. Have you ever missed a bracket while defining a method or semicolon at the end of a statement? We all do this silly mistake every time we code. In this article, we are going to explore the importance of these separators and what would be the consequences if we neglect them. Seperators available in Java Being a programmer we ... Read More

Sorting Elements of Arrays and Wrapper Classes that Already Implements Comparable in Java

Shriansh Kumar
Updated on 12-May-2023 17:29:57

206 Views

Java provides a variety of sorting algorithms and methods that can help us to sort arrays, lists or any collections. The comparable interface is an additional way that is useful when we want to sort custom objects by their natural ordering. For example, It sorts strings in dictionary order and numerics in numerical order. This interface is available in ‘java.lang’ package. In this article, we will create an array and arraylist and then, try to sort them to show that arrays and wrapper classes already implements Comparable Interface. Sorting elements of Arrays and Wrapper class We will use the following ... Read More

Sorting Custom Object by Implementing Comparable Interface in Java

Shriansh Kumar
Updated on 12-May-2023 17:27:45

473 Views

Java provides a variety of sorting algorithms and methods that can help us to sort arrays, lists or any collections. The comparable interface is an additional way that is useful when we want to sort custom objects by their natural ordering. For example, it sorts strings in dictionary order and numerics in numerical order. This interface is available in ‘java.lang’ package. In this article, we will learn the use of Comparable Interface through examples. Also, we discuss a few methods and classes of Collection Interface that are going to help us in sorting of custom objects using comparable interface. ... Read More

Sorting a 2D Array according to values in any given column in Java

Shriansh Kumar
Updated on 12-May-2023 17:26:18

973 Views

Array is a linear data structure that is used to store a 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 is of fixed length. Suppose we have a 2D array of order M x M where M is the number of rows and columns. We have to sort the specified column of the given array. In this article, we will try to find the solution to the given problem. Sorting 2D Array according to column value Sorting means rearranging the elements of a ... Read More

Java Program for Minimum product subset of an array

Shriansh Kumar
Updated on 12-May-2023 17:23:29

212 Views

Array is a linear data structure that is used to store a 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 is of fixed length. The problem statement states that for a given array we have to find the minimum product of its subset. In this article, we will try to find the solution to the given problem. Program for minimum product of subsets Example 1 Let’s try to understand the problem and possible solution through an example. For the above ... Read More

Advertisements