Object Oriented Programming Articles

Page 267 of 589

Sort Java Vector in Descending Order using Comparator

Shriansh Kumar
Shriansh Kumar
Updated on 15-May-2023 647 Views

Vectors implement the List interface and are used to create dynamic arrays. The array whose size is not fixed and can grow as per our needs is called as a dynamic array. The Comparator is an interface available in ‘java.util’ package. Sorting means rearranging the elements of a given list or array in ascending or descending order. In this article, we will create a vector and then try to sort its elements in descending order using a comparator. Program to Sort Java Vector in Descending Order Comparator As the name suggests it is used to compare something. In ...

Read More

Runtime Type Identification in Java

Shriansh Kumar
Shriansh Kumar
Updated on 15-May-2023 1K+ Views

Runtime Type Identification in short RTTI is a feature that enables retrieval of the type of an object during run time. It is very crucial for polymorphism as in this oops functionality we have to determine which method will get executed. We can also implement it for primitive datatypes like Integers, Doubles and other datatypes. In this article, we will explain the use case of Runtime Type Identification in Java with the help of examples. Program for Runtime Type Identification Let’s discuss a few methods that can help us to identify type of object: instanceOf It is a ...

Read More

Runtime JAR File in Java

Shriansh Kumar
Shriansh Kumar
Updated on 15-May-2023 938 Views

The full form of JAR is Java Archive File. Java provides this feature to bundle multiple java program files as well as their corresponding class files into one single unit. Perhaps, it is the only file format that can store audio, video, text files and so forth in one place. In this article, we will discuss how we can create and access a JAR file in Java. Java JAR File The need for data compression was felt to store and transmit large amounts of data without any hassle. For this purpose, a ZIP file was introduced that encouraged Java creators ...

Read More

Rounding off errors in Java

Shriansh Kumar
Shriansh Kumar
Updated on 15-May-2023 1K+ 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

System.out.println in Java

Siva Sai
Siva Sai
Updated on 15-May-2023 56K+ Views

Introduction System.out.println is a method in Java that prints a message to the standard output (typically the console) and appends a newline character. It's widely used to display messages, data, and the results of operations during the execution of a program. This method is essential for understanding the flow of your code and debugging potential issues. Breaking Down System.out.println System.out.println may seem like a simple method, but it's worth understanding its components to get a better grasp of how it works. System − A built-in class in the java.lang package. It cannot be instantiated and provides access to standard input, output, ...

Read More

Swapping items of a list in Java _ Collections.swap() with Example

Siva Sai
Siva Sai
Updated on 15-May-2023 450 Views

This article will provide an in-depth explanation of how to swap items in a list using the Collections.swap() method in Java. This topic is crucial for anyone looking to strengthen their data manipulation skills in Java, especially in dealing with list data structures. Java provides an extensive suite of tools for manipulating collections, including lists. One of these tools is the Collections.swap() method, which allows developers to easily swap the positions of two elements in a list. This method can be extremely handy when you need to rearrange elements in a list for various purposes, such as sorting, shuffling, or ...

Read More

Swap Corner Words and Reverse Middle Characters

Siva Sai
Siva Sai
Updated on 15-May-2023 538 Views

In this article, we'll delve into a fascinating string manipulation problem that involves swapping corner words of a string and reversing the middle characters. This kind of problem is quite common in coding interviews, and it's a great way to enhance your understanding of string manipulation in Java. Java provides a rich set of tools for string manipulation. From basic operations such as concatenation and comparison to more complex tasks such as string reversing and swapping, Java's String API can handle it all. One intriguing problem is to swap the corner words of a string and reverse the middle characters. ...

Read More

Sum of Array Divisible by Size with Even and Odd Numbers at Odd and Even Index in Java

Siva Sai
Siva Sai
Updated on 15-May-2023 360 Views

Understanding how arrays work is fundamental for any developer, and Java is no exception. Arrays in Java are objects that store multiple variables of the same type. However, arrays can often be used in more complex ways. One such instance is when you need to figure out if the sum of an array, considering only even numbers at odd indices and odd numbers at even indices, is divisible by the size of the array. In this article, we will guide you step-by-step on how to solve this problem. Problem Statement Given an array of integers, write a function in Java ...

Read More

Rules For Variable Declaration in Java

Shriansh Kumar
Shriansh Kumar
Updated on 12-May-2023 2K+ 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
Shriansh Kumar
Updated on 12-May-2023 2K+ 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
Showing 2661–2670 of 5,881 articles
« Prev 1 265 266 267 268 269 589 Next »
Advertisements