Skip to content

Instantly share code, notes, and snippets.

View gauravkukade's full-sized avatar

Gaurav Kukade gauravkukade

View GitHub Profile
@gauravkukade
gauravkukade / ArrayListSubListExample.java
Created December 24, 2021 08:35
A java program to explain the subList() method of the ArrayList class in Java. Read more at https://coderolls.com/sublist-method-in-arraylist/
import java.util.ArrayList;
import java.util.List;
/**
* A java program to explain the subList() method of the ArrayList class in Java
*
* @author Gaurav Kukade at coderolls.com
*
*/
public class ArrayListSubListExample {
@gauravkukade
gauravkukade / ArrayListRetainAllExample.java
Created December 24, 2021 08:34
A java program to to eplain the retainAll() method of the Arraylist class. Read more at https://coderolls.com/arraylist-retainall-method/
import java.util.ArrayList;
import java.util.List;
/**
* A java program to to eplain the retainAll() method of the Arraylist class.
*
* @author Gaurav Kukade at coderolls.com
*
*/
public class ArrayListRetainAllExample {
@gauravkukade
gauravkukade / MyArrayList.java
Created December 24, 2021 08:33
A java program to remove the range of elements from the MyArraylist (a class which extends the ArrayList) using the removeRange() method. The removeRange() method is protected and is accessed in class, subclasses and in a package, but not public. Read more at https://coderolls.com/arraylist-removerange-method/
package com.gaurav.ExProject.ArrayList;
import java.util.ArrayList;
import java.util.List;
/**
* A java program to remove the range of elements from
* the MyArraylist (a class which extends the ArrayList)
* using the removeRange() method.
*
@gauravkukade
gauravkukade / ArrayListGetExample.java
Created December 24, 2021 08:31
A java program to get the element by its index using the get() method. Read more at https://coderolls.com/arraylist-get-method/
import java.util.ArrayList;
import java.util.List;
/**
* A java program to get the element by
* its index using the get() method
*
* @author Gaurav Kukade at coderolls.com
*/
public class ArrayListGetExample {
@gauravkukade
gauravkukade / ArrayListAddAllExample2.java
Created December 24, 2021 08:28
A Java program to add all elements of the specified collection to the ArrayList from a particular index. Read more at https://coderolls.com/arraylist-addall-method-in-java/
import java.util.ArrayList;
import java.util.List;
/**
* A Java program to add all elements of the specified collection
* to the ArrayList from a particular index
*
* @author Gaurav Kukade at coderolls.com
*/
public class ArrayListAddAllExample2 {
@gauravkukade
gauravkukade / ArrayListAddAllExample.java
Created December 24, 2021 08:27
A Java program to add all elements of the specified collection to the end of the ArrayList. Read more at https://coderolls.com/arraylist-addall-method-in-java/
import java.util.ArrayList;
import java.util.List;
/**
* A Java program to add all elements of the specified collection
* to the end of the ArrayList
*
* @author Gaurav Kukade at coderolls.com
*/
public class ArrayListAddAllExample {
@gauravkukade
gauravkukade / ArrayListToArray2.java
Created December 24, 2021 08:21
A java program to convert an ArrayList to array using toArray() method. toArray(T[] a) method returns T[], Read more at https://coderolls.com/convert-arraylist-to-array/
import java.util.ArrayList;
/**
* A java program to convert an ArrayList to array using
* toArray method.
*
* toArray(T[] a) method returns T[]
*
* @author Gaurav Kukade at coderolls.com
*
@gauravkukade
gauravkukade / ArrayListToArray.java
Created December 24, 2021 08:20
A java program to convert an ArrayList to array using toArray() method. toArray() method returns Object[], Read more at https://coderolls.com/convert-arraylist-to-array/
/**
* A java program to convert an ArrayList to array using
* toArray method.
*
* toArray() method returns Object[]
*
* @author Gaurav Kukade at coderolls.com
*
*/
public class ArrayListToArray {
@gauravkukade
gauravkukade / ArrayListContainsMethodExample.java
Created December 24, 2021 08:18
A java program to check if the ArrayList contains the specified element. Read more at https://coderolls.com/arraylist-contains-method/
import java.util.ArrayList;
import java.util.List;
/**
* A java program to check if the ArrayList
* contains the specified element.
*
* @author Gaurav Kukade a coderolls.com
*/
public class ArrayListContainsMethodExample {
@gauravkukade
gauravkukade / ArrayListClearMethodExample.java
Created December 24, 2021 08:16
A java program to remove all the elements of ArrayList using the clear() method. Read more at https://coderolls.com/arraylist-clear-method-in-java/
import java.util.ArrayList;
import java.util.List;
/**
* A java program to remove all the elements
* of ArrayList using the clear() method.
*
* @author Gaurav Kukade at coderolls.com
*
*/