Found 2797 Articles for Java

Compile Time Polymorphism in Java

Rudradev Das
Updated on 29-Dec-2023 15:49:04

55 Views

The polymorphism is a declaration of an object capacity present in a Java environment. It allows us to perform the same process in different manner. There are two types of polymorphism present in Java − Compile-time polymorphism method Run time polymorphism method Today, we are going to discuss about the compile time polymorphism by using the Method overloading and Operator overloading. Here is an example − void ARBRDD() { ... } void ARBRDD(int num1 ) { ... } void ARBRDD(float num1) { ... } void ARBRDD(int num1 , float num2 ) { ... } show the value of ( char a ) show the value of ( char a ,char b ) show the ... Read More

Comparing Two ArrayList In Java

Rudradev Das
Updated on 27-Dec-2023 16:57:33

62 Views

There are various methods available, to compare the two particular array lists by using a Java environment. It consists of the array lists, as they are same in the size and should contain with the same elements in that particular lists. Here are some process mentioned below − Java equals() method Java removeAll() method Java retainAll() method Java ArrayList.contains() method Java contentEquals() method java.util.ArrayList method For this process − This particular function has a single parameter value to be compared for the equality. The process will return a true pop up if the array lists are equal. ... Read More

Comparing Streams to Loops in Java

Rudradev Das
Updated on 27-Dec-2023 18:07:57

49 Views

Stream is a pipeline system, which is mainly used to aggregate some operations like (filter(), map(), forEach(), and collect()) in a Java environment. This function consists of a source which is followed by the value of zero and then terminate the operation. A function is an input output stream whis mainly depends on the input arguments. Every stream works when − It starts from a data source. Process the data elements through a pipeline. Terminates itself in a terminal operation. Here is an example − Benchmark Is Here Mode Cnt Score Error Units ForLoopPerformanceTest.usingForEachLoop thrpt 20 259.008 ... Read More

Comparator Interface in Java with Examples

Rudradev Das
Updated on 27-Dec-2023 18:06:31

29 Views

The comparator interface is an interface class of the Java interface calss, which is able to order the user defined array elements. The comparator object is much more capable to handle the comparing operation of a same class. Here is an example − Unsorted List Is Here 111 ARB Pfarrkirchen 131 RDD Ingolstadt Sorting process on the basis of rollno 101 AGB Dhaka 111 ARB Pfarrkirchen Sorted process on the basis of name 101 AGB Dhaka 111 ARB Pfarrkirchen Lets see some advantages of the comparator interface class − The process of sorting based on the different ... Read More

Comparable Interface in Java with Examples

Rudradev Das
Updated on 27-Dec-2023 18:01:06

42 Views

Comparable interface is a comparator class, which is mainly used to compare the objects present in a same class. The method provides the output as an ordered set by using the user defined data set in an array list. It is also an instance class, which is mainly for the compareTo methods those can consider the parameter of a particular class objects. While we use a comparable interface − We initiate the method from the java.lang package in a particular pair class. The method interface contains a compareTo method where we can decide the order of those elements. We ... Read More

Commonly Used Methods in LocalDate, LocalTime and LocalDateTime Classes in Java

Rudradev Das
Updated on 27-Dec-2023 17:57:41

29 Views

There are three types of most important classes we can find in a Java environment, related to date and time. LocalDate, LocalTime and LocalDateTime are available in the Java programming to handle the operations related with the date and time problems. Here we need to import the Java package as java.time which is a main application programming interface aka API for date, time, instants, and the time durations. Purpose of the LocalDate, LocalTime and LocalDateTime classes are − java.time.* //It is the process to include all classes java.time.LocalDate //It is the process for LocalDate java.time.LocalDateTime //It is the process ... Read More

Collections.sort() in Java with Examples

Rudradev Das
Updated on 27-Dec-2023 17:45:36

27 Views

The collection class is an enhanced static method to sort the elements from a particular collection of a list or an array. For this process, we can use a tree set also, when we operate on a set of elements as present as the raw set type primarily. The Collections.sort() method is present in the java.util.Collections class, and enables the user to sort the elements from a specific list in an ascending order. The method is an upgraded version of the java.util.Arrays.sort() method class, which is capable to sort the elements from a linked list as well as queue and ... Read More

Collections.reverseOrder() in Java with Examples

Rudradev Das
Updated on 27-Dec-2023 17:43:20

38 Views

Collections reverse order class is a reverse order method, which is encoded in the collections class. It is present in the java.util package. It returns a comparator as a result, which is a predefined comparator in nature. By using this comparator package, we can rearrange the collections of a particular data set in a reverse manner. There are two different variants of the Java reverseOrder(), which can be defined as per the capacity of their parameters. Those are − Java Collections reverseOrder() Method − is used to get the value of a comparator class which can impose the reverse ... Read More

Java program to iterate over arrays using for and foreach loop

Shubhi Rastogi
Updated on 21-Nov-2023 17:59:22

324 Views

In the article, the users will learn how to iterate the arrays for each loop and for loop with the examples. Create an array with the data that have any type of the data like numeric or statement form in the array. Let’s announce any string array known as designations, and initialize the array with the items as input like this. Then the users have to iterate this array with the loops and print each element. for(String designation: designations){} The users affirm a loop variable. The users have been given a string array because each element is a string In this array so ... Read More

Java program to merge two arrays

Shubhi Rastogi
Updated on 21-Nov-2023 17:53:28

208 Views

In the article, the users are going to merge two arrays. The users create any type of two arrays as input like arr1[] and arr2[] with the examples. The users have to create the two types of arrays with multiple elements as the inputs and it presents the result with different elements as the output. Print all of the elements of the array in the sorted sequence in Java programming language. Two approaches are illustrated in this article. The first approach uses the concept of the arrays whereas the second approach represents the Map function to merge to arrays. The ... Read More

Advertisements