
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

791 Views
In this article, we will understand how to convert the array into a collection in Java. The Collection is a framework that provides an architecture to store and manipulate the group of objects. Java Collections can achieve all the operations that you perform on data such as searching, sorting, insertion, manipulation, and deletion. Problem Statement Write a program in Java to convert the array into the collection. Below is a demonstration of the same − Input Input array: [Java, Python, Scala, Shell] Output After elements after converting the array to a list ... Read More

1K+ Views
The Collection is a framework that provides architecture to store and manipulate a group of objects. Java Collections can achieve all the operations that you perform on data, such as searching, sorting, insertion, manipulation, and deletion. In this article, we will understand how to convert a collection into an array in Java. Following are the ways to convert a collection into an array in Java: Using Iteration Using toArray() Method Using Streams Collection to Array using Iteration The naive way to convert a collection into an array is by traversing the collection and adding each element in the ... Read More

3K+ Views
A string is a class in Java that stores a series of characters enclosed within double quotes, and a continuous sequence of characters within that string is known as a substring. Those characters are string-type objects. In this article, we will learn how to write Java programs to check if a string contains a substring or not. Java Program to Check if a String Contains a Substring We can check whether the given string contains a substring or not in the following ways: Using indexOf() Method Using contains() Method ... Read More

376 Views
The Collection is a framework that provides an architecture to store and manipulate a group of objects. In Java, Collections can perform all the operations that you perform on data, such as searching, sorting, insertion, manipulation, and deletion. In this article, we will learn how to shuffle the elements of a collection in Java. Shuffling refers to randomly rearranging the elements of a collection. Let's take an example as follows: Input: list: [Java, program, is, fun, and, easy] Output: list: [fun, easy, Java, program, and, is] Ways to Shuffle Elements of a Collection in Java ... Read More

2K+ Views
Time formatting is a process of converting date and time values into human-readable strings with specific formats. The resulting string describes how date/time values should be represented (such as flat files or human-readable output). In this article, we will understand how to format time in AM-PM format. In 12-hour clock system, AM-PM format is used to define time. Here, AM stands for Ante meridiem which refers to the time before noon, whereas PM stands for Post meridiem which shows the time period after noon. Example Scenario Input: current_date = Thu Mar 17 16:04:31 IST 2024 Output: Current Time ... Read More

206 Views
The Collection is a framework that provides architecture to store and manipulate the group of objects. Java Collections can achieve all the operations that you perform on a data such as searching, sorting, insertion, manipulation, and deletion. In this article we will look at how to get the size of a collection in Java. The size of a collection is the number of elements it contains. Following are the ways to get the size of a collection in Java: Using size() Method Using loops Using Streams API Getting Size of Collection Using size() Method The size() method is ... Read More

2K+ Views
To convert a given string into an InputStream, Java provides the ByteArrayInputStream class that is used along with a built-in method named getBytes(). While displaying a long input string, we are sometimes required to process it in smaller units. At that time, converting that string into an InputStream will be helpful. In this article, we will learn how we can use the ByteArrayInputStream class to convert a string into an InputStream with the help of example programs. Before discussing that, we need to learn about the InputStream and BufferedReader classes and the getBytes() method first: InputStream Class There are two fundamental ... Read More

811 Views
In Java, the Collection framework provides an architecture to store and manipulate a group of objects. Collections support operations such as searching, sorting, insertion, manipulation, and deletion. In this article, we will learn how to compare elements in a collection in Java using different approaches. Before learning about the methods, let us understand the problem with the help of the following input-output scenarios: Scenario 1 Input: ["Java", "Python", "JavaScript", "C++"] Element to Compare: "Java" Output: Java is equal to Java Python is not equal to Java JavaScript is not equal to Java C++ is not equal to ... Read More

913 Views
In this article, we will understand how to print a collection in Java. The Collection is a framework that provides architecture to store and manipulate the group of objects. Java Collections can achieve all the operations that you perform on a data such as searching, sorting, insertion, manipulation, and deletion. Problem Statement Write a program in Java to print a Collection. Below is a demonstration of the same − Input Run the program Output The Elements of the collection are: Language : Java | Language_id : 101 Language : Scala | Language_id : 102 Language : Python | Language_id : ... Read More

890 Views
An enum is a special "class" that represents a group of constants (unchangeable variables, like final variables). For example, we have constants like week days, months, or set of languages etc. In Java, we can create an enum to represent these constants. In this article, we will learn how to lookup an enum by its string value in Java. Java Program to Lookup Enum by String Value lets learn how you can convert a string to its corresponding enum value using the following ways and also print the enum value: Using valueOf() Method Using EnumSet and stream() Using ... Read More