
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
Mahesh Parahar has Published 191 Articles

Mahesh Parahar
12K+ Views
Elements can be checked from a list using indexOf() or contains() methods.Syntax - indexOf() methodint indexOf(Object o)Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ... Read More

Mahesh Parahar
314 Views
Streams can be used to search an item within list.Student student2 = list.stream().filter(s -> {return s.getRollNo() == rollNo);}).findAny().orElse(null);In this example, we're searching a student by roll number.ExampleFollowing is the example showing the usage of streams to search an item in a list −package com.tutorialspoint; import java.util.ArrayList; import java.util.List; ... Read More

Mahesh Parahar
303 Views
The List provides two methods to convert a List into Array.Way #1Object[] toArray()Returns an array containing all of the elements in this list in proper sequence (from first to last element).Way #2 T[] toArray(T[] a)Returns an array containing all of the elements in this list in proper sequence (from first ... Read More

Mahesh Parahar
675 Views
An ArrayList provides two methods to convert it into Array.Way #1Object[] toArray()Returns an array containing all of the elements in this list in proper sequence (from first to last element).Way #2 T[] toArray(T[] a)Returns an array containing all of the elements in this list in proper sequence (from first to ... Read More

Mahesh Parahar
398 Views
A list can be converted to a set object using Set constructor. The resultant set will elliminate any duplicate entry present in the list and will contains only the unique values.Set set = new HashSet(list);On similar pattern, we can get a list from a set using its constructor.List list = ... Read More

Mahesh Parahar
257 Views
The List provides two methods to convert a List into Array.1. Use toArray() method without parameter.Object[] toArray()ReturnsAn array containing all of the elements in this list in proper sequence.2. Use toArray() with array. T[] toArray(T[] a)Type ParameterT − The runtime type of the array.Parametersa − The array into which the ... Read More

Mahesh Parahar
245 Views
A list can be converted to a set object using Set constructor. The resultant set will elliminate any duplicate entry present in the list and will contains only the unique values.Set set = new HashSet(list);Or we can use set.addAll() method to add all the elements of the list to the ... Read More

Mahesh Parahar
519 Views
The List provides two methods to convert a List into Array.1. Use toArray() method without parameter.Object[] toArray()ReturnsAn array containing all of the elements in this list in proper sequence.2. Use toArray() with array. T[] toArray(T[] a)Parametersa − The array into which the elements of this list are to be stored, ... Read More

Mahesh Parahar
727 Views
List provides a method size() to check the current size of the list.Syntaxint size()Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.ReturnsThe number of elements in this list.ExampleThe following example shows how to get size of a list using size() method.package ... Read More