
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7442 Articles for Java

956 Views
Every Java programmer whether a beginner or experienced, encounters numerous errors while writing code. Generally, these errors are categorized as run time and compile time errors. The run-time error occurs while running the code after successful compilation and the compile-time error during compilation. The class, interface, or enum expected is an error thrown during the compilation of source code. It may occur due to several reasons, one of them being misplaced curly braces. In this article, we are going to explore the reasons for this error and corresponding ways to fix the class, interface, or enum expected error. ... Read More

523 Views
TreeMap is a class of Java Collection Framework that implements NavigableMap Interface. It stores the elements of the map in a tree structure and provides an efficient alternative to store the key-value pairs in sorted order. Note that while creating objects of TreeMap it is necessary to use either the Comparable Interface or Comparator Interface so that we can maintain the sorting order of its elements otherwise, we will encounter a java.lang.ClassCastException. In this article, we are going to explain how to use the Comparable and Comparator Interfaces to fix this ClassCastException in TreeMap. Fixing java.lang.ClassCastException in TreeMap ... Read More

238 Views
The TreeSet is a generic class of Java Collection Framework that implements the SortedSet Interface. It stores the elements of the set in a tree structure. Furthermore, all the elements are stored in a sorted manner and they must be mutually comparable if we are attempting to add custom class objects otherwise we will encounter a java.lang.ClassCastException. Here, custom class objects mean user-defined objects that are created with the help of a constructor. To fix this ClassCastException in TreeSet we can use either the Comparator Interface or the Comparable Interface. Let's discuss them in detail. The general ... Read More

189 Views
The TreeSet is a generic class of Java Collection Framework that implements the SortedSet Interface. It stores the elements of the set in a tree structure. Furthermore, all the elements are stored in a sorted manner and they must be mutually comparable if we are attempting to add custom class objects otherwise we will encounter a java.lang.ClassCastException. Here, custom class objects mean user-defined objects that are created with the help of a constructor. One way to fix this ClassCastException is by using a custom comparator. Let's discuss it in detail. The general syntax for TreeSet is as ... Read More

409 Views
LinkedHashMap is a generic class of Java Collection Framework that implements Map Interface. As the name suggests, it is a sub-class of the HashMap class and uses a doubly LinkedList to store the entries in insertion order. It maintains Key-Value pair of entries. The Key is an object that is used to fetch and receive value associated with it. Hence, we can use this key along with 'get()' method to get all the values from LinkedHashMap. The aim of this article is to explain different ways to print all values of the LinkedHashMap. Java Program to Get all ... Read More

744 Views
LinkedHashMap is a generic class of Java Collection Framework that implements Map Interface. As the name suggests, it is a sub-class of the HashMap class and uses a doubly LinkedList to store the entries in insertion order. However, LinkedHashMap does not do any kind of indexing to store the entries, therefore, it is quite a challenge to get specified values from LinkedHashMap with the help of an index. The aim of this article is to explain how to find a value from LinkedHashMap using the index. Java Program to Get a Value from LinkedHashMap by Index Before jumping ... Read More

177 Views
LinkedHashSet is a class of Java Collection Framework that implements the Set interface and extends the HashSet class. It is a linked list type of collection class. It stores and returns the objects in the order in which they were inserted. Finding maximum and minimum elements from a LinkedHashSet collection is one of the common tasks that are frequently asked in exams and even in job interviews. In this article, we are going to explore a few approaches for performing the given task. Program to get Minimum and Maximum elements from LinkedHashSet To find the maximum ... Read More

3K+ Views
In Java, Map is an object that stores its element in key-value pairs. The Key is an object that is used to fetch and receive value associated with it. The keys must be unique, but the values associated with them may be duplicated depending on the type of Map class we use. There are several approaches to find an entry with the largest key in Java map and these approaches also depend on the type of Map class we are working with. In this article, we will discuss how to find the entry with largest key in HashMap ... Read More

698 Views
Multithreading is a feature of the Java programming language that allows us to perform multiple operations simultaneously. In it, the operation gets divided into multiple smaller parts called a thread. Each thread performs one independent task without affecting the other thread's performance. The main benefit of multithreading is the optimal use of resources like CPU and it boosts the execution time of allocated operations. Finding prime and palindrome numbers are two of the basic programming task that every beginner programmer perfroms. However, in this article, we are going to do the same task in an exciting way. We will ... Read More

2K+ Views
Memory management is an important aspect of any Java application. Having the knowledge of how much memory is available, how much is used and how much is free may help you to optimize your code and avoid performance issues or memory leaks. This article aims to help in finding max memory, free memory and total memory that are a crucial part of Java Heap. Note that the amount of memory allocated to a Java program depends on the environment. Java Program to find Max Memory, Free Memory and Total Memory Java provides the following methods and classes that ... Read More