Found 9321 Articles for Object Oriented Programming

Java Program to search ArrayList Element using Binary Search

Rudradev Das
Updated on 10-Apr-2023 15:50:56

363 Views

Searching is a sorting process to find a particular information from a set of random elements. In a Linear Data structure, there are two types of searching process - Linear Search Binary Search Linear search is a simple searching method by which we can find an element from a data source in a sequential manner. For this searching process the best execution time is 1 and worse is always considered as n. Binary search is a searching process of a particular key element from a stock of multiple elements which follows divide and conquer approach. In this search ... Read More

Java TreeSet Special Method

Rudradev Das
Updated on 10-Apr-2023 15:44:02

123 Views

The TreeSet class in Java environment is a container interface set that is mainly use to store tree. There are two different ways in this class. An AbstractSet Class - It is a collection interface, part of the Java Collection Framework. NavigableSet interface - It is a navigable collection set in Java Collection. Here in the Java environment, TreeSet inherits AbstractSet class and carry through the NavigableSet. Some important aspects of TreeSet implementation − It takes unique data as input. Don't save insertion order of the data. Sorts elements in an ascending order. Thread unsafe. ... Read More

Java TreeMap Special Methods

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

139 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

206 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 10-Apr-2023 15:33:43

871 Views

What are the Time Operations in Java? There are two time operations provided by Java environment. For the time related operation, users can use these operations. System.nanoTime() System.currentTimeMillis() System.nanoTime() mainly known as expensive call, used to get more specific value of time. And, System.currentTimeMillis() most authentic possible passed time, helps to get the time value based on the operating system basically. The first function returns the time value in Nano Seconds (can give negative value sometimes) and on the other hand second function in milliseconds. So it's obvious, System.nanoTime() is one step ahead and more acceptable ... Read More

Java Program to Find Sum of Natural Numbers Using While Loop

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

390 Views

Sum of Natural Numbers can be calculated using different Iterative Statements in Programming Languages. Iterative Statements are statements which execute a particular set of code lines until the condition in the loop statement is failed. In this article, we will discuss how to calculate Sum of Natural Numbers using a while- loop which is an iterative statement in Java Programming Language. 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) + ... Read More

Java Program to Find Area of Square Using Method Overloading

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

1K+ 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

4K+ 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 10-Apr-2023 16:40:22

995 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. Examples Input: array = {1, 7, 2, 3, 9, 5, 10} Output: Maximum odd number is 9 From the above example, in the array the maximum odd number is 9. ... Read More

Advertisements