Found 9150 Articles for Object Oriented Programming

Java TreeMap Special Methods

Rudradev Das
Updated on 10-Apr-2023 15:38:22

252 Views

The TreeMap is a method class collection framework in Java environment. It is storing key to implement a Map Interface or a Map Navigation with a MapAbstract class. After the sorting process the keys of that map will store in the natural order in a consistent manner. The implementation of a TreeMap may not be in an organized manner because the specific map can be addressed by multiple threads. A TreeMap function implemented by using a self-balancing Red-Black binary tree. This method is really efficient to perform addition, remove and retrieve for some elements with O(log n) time complexity. Now ... Read More

Java Ternary Operator Puzzle

Rudradev Das
Updated on 10-Apr-2023 15:36:18

305 Views

What Is An Operator In Java Environment? Operators are some special characters or symbols or data indicators those are able to perform some specific operations in Java environment. There are multiple operands (variables), which can take part here in this operation. After a successful compilation we get the desired output. There are many operators present in Java language, which are mainly used to manipulate the actual values of the key variables present in a Java build code. For the ternary operation there is a condition followed by the question mark (?), then an expression to execute the method if the ... Read More

Java System.nanoTime() vs System.currentTimeMillis

Rudradev Das
Updated on 07-Aug-2024 21:46:13

1K+ Views

What are the Time Operations in Java? There are two-time operations provided by the Java environment. For time-related operations, users can use these operations. System.nanoTime() System.currentTimeMillis() System.nanoTime() mainly known as an expensive call, is used to get a more specific value of time. And, System.currentTimeMillis() most authentic possible passed time, helps to get the time value based on the operating system. ... Read More

Java program to find sum of natural numbers using while loop

Shiva Keerthi
Updated on 05-Sep-2024 11:23:05

662 Views

The sum of natural numbers can be calculated using different Iterative Statements in Programming Languages. Iterative Statements are statements that execute a particular set of code lines until the condition in the loop statement fails. In this article, we will discuss how to calculate the sum of natural numbers using a while-loop which is an iterative statement in Java. Sum of Natural Numbers The sum of natural numbers generally indicates the total sum of elements from 1 to n. Mathematically it can be represented as follows Sum of n Natural Numbers = 1+2+3+.........+(n-2) + (n-1) + n ... Read More

Java Program to Find Area of Square Using Method Overloading

Shiva Keerthi
Updated on 11-Apr-2023 12:47:11

2K+ Views

We can calculate the area of the square 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. Method Overloading helps us to increase the readability of the code so that we can use the same method in different ways. Now, let us ... Read More

Java Program to find Square Root of a number using Binary Search

Shiva Keerthi
Updated on 10-Apr-2023 16:45:00

2K+ Views

Square Root of a number is an integer value when multiplied by itself, gives the original number. In this article, we are going to write a java program to find the square root of a number using binary search. Finding square root of a number is one of the application of the binary search algorithm. We will discuss in detail how we calculate the square root using binary search in this article. Examples Input: 64 Output: 8 As, the square root of 64 is 8, the output is 8. Input: 16 Output: 4 As, ... Read More

Java Program to Find out the Area and Perimeter of Rectangle using Class Concept

Shiva Keerthi
Updated on 31-May-2024 16:30:49

8K+ Views

Java Language is one of the most used popular object - oriented programming language in present world. Class concept is one of the most important feature in Object - oriented languages. A Class is a like a blue print of an object. For example, when we want to build a house we first create a blue print of the house in other words we create a plan showing how we are going to build the house. Based on the plan we can create a number of houses. Similarly using class, we can create a number of objects. A class ... Read More

Java program to find maximum odd number in array using stream and filter

Shiva Keerthi
Updated on 25-Jul-2024 19:32:19

2K+ Views

In this section, we are going to write a Java program to find maximum odd number in an Array using Stream and Filter. Odd numbers are the numbers which cannot be divided by 2 or these numbers give remainder as 1 when they are divided by 2. In other terms which can be written in the form of 2n+1. We will find the maximum odd number in the array. Problem Statement Write a program in Java to find maximum odd number in array using stream and filter − Input array = {1, 7, 2, 3, 9, ... Read More

Java program to find Harmonic series

Shiva Keerthi
Updated on 26-Feb-2025 16:48:17

1K+ Views

The reciprocals of an arithmetic series without considering 0 is known as Harmonic series. If $a_{1}, a_{2}, a_{3}$… is arithmetic series then $\frac{1}{a1}$, $\frac{1}{a2}$, $\frac{1}{a3}$, … is the harmonic series. In this article, we will discuss how to implement a Java program to find the harmonic series. Harmonic Series For 1st term n = 1 and for every term n is incremented by 1 and at last the nth term the value is ‘n’. Harmonic series : $1+\frac{1}{2}+\frac{1}{3}$.......+$\frac{1}{n}$ Where, 1/n is the nth term of harmonic series. Problem Statement Write a Java program to find the ... Read More

Java Program to Find G.C.D and L.C.M of Two Numbers Using Euclid's Algorithm

Shiva Keerthi
Updated on 10-Apr-2023 16:20:17

3K+ Views

Euclid’s Algorithm is an efficient algorithm which helps us to find G.C.D and L.C.M of two numbers. In this article, we are learning to write a Java program to find the G.C.D and L.C.M of two numbers using Euclid’s Algorithm. G.C.D. of two numbers G. C. D, known as Greatest Common Divisor is the highest common factor that divides the two given numbers exactly. Now let us look into an example and calculate the G.C.D of a two numbers. Factors − In mathematics, Factors are the numbers that can divide a given number. Ex − 8 can be divided ... Read More

Advertisements