Found 9150 Articles for Object Oriented Programming

Java Program to Find Chromatic Index of Cyclic Graphs

Shiva Keerthi
Updated on 10-Apr-2023 16:19:02

192 Views

Chromatic Index of a graph is the parameter which indicates the minimum number of colours needed to colour all the edges of graph such that no two edges sharing the common vertex have same coloured edge. In this article, we will discuss how to find the chromatic index of cyclic graphs using the Java programming language. What is a Cyclic Graph? Cyclic Graph is a graph which consists of at least one cycle path in that particular graph. Cyclic path is a path that starts from a specific node and ends at the same node. What is Graph Colouring? ... Read More

Java Program to Find Common Elements Between Two Arrays

Shiva Keerthi
Updated on 31-May-2024 15:06:05

11K+ Views

We can use different approaches in Java to Find Common Elements between two arrays. We will discuss the approaches, including the basic steps involved, and provide the necessary code to achieve our goal. Whether you are a beginner or an experienced Java programmer, this article will provide you with the tools and knowledge necessary to solve this common programming problem. In this article, we will learn different ways of finding the common elements between two arrays. Examples for Common Elements Between Two Arrays: Example 1: Input: array1 = {4, 2, 3, 1, 6} array2 = {6, 7, 9, ... Read More

Java program to find cube root of a number using binary search

Shiva Keerthi
Updated on 30-Aug-2024 11:41:47

1K+ Views

The cube root of a number is an integer value when multiplied by itself thrice, giving the original number. In this article, we are going to write a Java program to find the cube root of a number using binary search. Finding the cube root of a number is one of the applications of the binary search algorithm. We will discuss in detail how we calculate the cube root using a binary search algorithm in Java. Problem Statement Write a Java program to find the cube root of a number using Binary Search − Input 1 64 Output 1 4 ... Read More

Java Program to Find Area of circle Using Method Overloading

Shiva Keerthi
Updated on 09-Jul-2024 12:23:14

2K+ Views

We can calculate the area of the circle in Java using Method Overloading. “Method Overloading” is a feature in Java that allows one to write more than one method in the same class using the same method name. It will enable us to declare more than one method with the same names but with different signatures i.e., the number of parameters in the method may be different or the datatype of parameters may be different. Now, let us achieve Method Overloading in Java by considering the “area of a circle” as an example. Before moving to an example, now ... Read More

Java Program to Find the GCDs of given index ranges in an array

Rudradev Das
Updated on 06-Apr-2023 15:22:34

276 Views

In the field of data structure, a range query is a pre-processing method to operate on some input data in an efficient manner. A range query is responsible to answer any query of the particular input on any data subset. If we want to copy some data columns from a table we need to maintain an index for that particular dataset. An index is a direct link or a key, which is designed to provide an efficient searching process in a data set. It is mainly used to speed up the data retrieving from a lost data source. In mathematics, ... Read More

Java program to find array sum using bitwise OR after splitting given array in two halves after K circular shifts

Rudradev Das
Updated on 06-Apr-2023 18:00:21

220 Views

Array is a set of a single non primitive similar data types (values or variables) that stores the elements in a memory with a fixed number of values. After creating an array with certain elements, the length of this data set became fixed. Here non primitive means, these data types can be used to call a method to perform a particular operation which can be null in character. Here the bitwise sum means, sum of certain numbers with an exactly 2 bits set. Bitwise OR denotes that each integer is present in a subarray. It is an adjacent non-void element ... Read More

Java Program to count inversions of size three in a given array

Rudradev Das
Updated on 23-Jan-2025 23:06:37

291 Views

In this article, we will learn how to count inversions of size three in a given array. The goal is to find how many triplets (i, j, k) exist such that i < j < k and arr[i] > arr[j] > arr[k].Understanding Inversion Count Inversion count is a step-counting method by which we can calculate the number of sorting steps taken by a particular array. It is also capable of counting the operation time for an array. But, if we want to sort an array in a reverse manner, the count will be the maximum number present in that array. Array: ... Read More

Java program to extract a single quote enclosed string from a larger string using Regex

Pranay Arora
Updated on 16-Sep-2024 23:24:33

1K+ Views

Regex or Regular Expression is the language used for pattern-matching and string manipulation. It consists of a sequence of characters that define a search pattern and can be used for performing actions like search, replace, and even validate on text input. A regular expression consists of a series of characters and symbols that amount to form a search pattern. In this article, we are going to see how to write a Java program to extract a single quote-enclosed string from a larger string using Regex. Java provides support for regex from the java.util.regex package. The pattern class represents a compiled ... Read More

Java Program to Display Name of the Weekdays in Calendar Year

Shriansh Kumar
Updated on 30-Sep-2024 15:56:38

747 Views

There are 5 weekdays in a week, which are Monday, Tuesday, Wednesday, Thursday and Friday. The two remaining days i.e. Saturday and Sunday make up the weekend. In this article, we will learn how to write a Java program to display name of the weekdays in a calendar year. Using the DateFormatSymbols Class The Java standard library's java.text package contains the DateFormatSymbols class which provides methods for retrieving and setting the following date and time symbols − Month and day names and abbreviations Day of the week names and abbreviations Era names AM/PM strings Time Zone Names and ... Read More

Java program to display name of months of calendar year in short format

Pranay Arora
Updated on 10-Oct-2024 11:35:28

890 Views

A year has 12 months which are named January, February, March, April, May, June, July, August, September, October, November, December. These are the complete names of the months and there are multiple ways to represent them like short format, complete format, MM or 2 integers format. In this article, we are going to see how to display names of months of calendar year in short format with the help of Java. There are numerous ways to do so and are as follows − Using a String Array ... Read More

Advertisements