Found 9326 Articles for Object Oriented Programming

Java Program to Check if two Arrays are Equal or not

Bharti Kumari
Updated on 10-Apr-2023 15:48:30

2K+ Views

Introduction In Java, we can check if two arrays are equal or not by comparing their elements. If the elements in both arrays are the same and appear in the same order, then the two arrays are considered equal. One way to check the equality of two arrays is to use the Arrays.equals method provided by the java.util package. This method takes two arrays as arguments and returns a boolean value indicating whether they are equal or not. The method compares the elements of the arrays in the same order, so if the order of the elements is not important, ... Read More

Java vs C#

Rudradev Das
Updated on 10-Apr-2023 15:59:23

210 Views

Java is a dynamic, secured and class based high level object oriented programming language developed by Oracle Corporation. On the other hand; C# is a .Net Framework object oriented programming language developed by Microsoft. Java and C# both are the general purpose programming paradigm or basically known as the imperative environment for coding. And these two languages are capable to provide some high level results as output. In a broad view there are many differences between these two OOPs − Java Runtime Environment designed to run a Java code where C# runs on CLR Environment (Common Language Runtime). Java ... Read More

Java Program to search ArrayList Element using Binary Search

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

357 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

119 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

138 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

204 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

857 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

375 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

Advertisements