You are on page 1of 48

Collections Framework

Java SE
Contents
• Overview

• Advantages

• Collection Interfaces
• Set Interface

• List Interface

• Queue Interface

• Deque Interface

• Map Interface

• Utility Classes
• Arrays

• Collections
Overview
• ပ"iuဂရမ(တစ(ခuတ,င( အခ/က(အလက(မ/23အ23 မည(သ67်ပu9စ9:ဖင7်
အသu93:ပuမည(ဆiuသ67် အခ/က(သည( လ,န(စ,2အeရ3@ကA3

• Java SE 1.4 အeရ2က(တ,င( Collections Framework ကiu စတင(


အသu93:ပuBiuင(ခC7

• Collection ဆiuသည(မD2 အခ/က(အလက(မ/23အ23 အစuလiuက( eဖ2(:ပ


အသu93:ပuBiuင(eသ2 Container Object မ/23

• Collection Framework တ,င(၊ Interfaces မ/23၊ General Purpose


Implementation Class မ/23၊ Special Implementations Class
မ/23၊ Legacy Class မ/23BDင(7 Utility Class မ/23 ပFဝင(Hကသည(
Advantages
• ပ"iuဂရမ(မ/23အ23 eရ3သ23ရ2တ,င( သက(သ2eစ:ခင(3

• Performance အ23 တiu3တက(eစBiuင(:ခင(3

• ပတ(သက(:ခင(3မIieသ2 ပ"iuဂရမ(မ/23 အHက23တ,င( အ:ပန(အလDန( ဆက(သ,ယ(


အသu93:ပueစBiuင(:ခင(3

• API အ23 eလ7လ2ရန( အခ/iန(အ23 သက(သ2eစ:ခင(3

• API အ23 eရ3သ23ရန( အခ/iန(အ23 သက(သ2eစ:ခင(3

• Software မ/23အ23 :ပန(လည(အသu93ခ/နiuင(eစရန( အeထ2က(အကL :ပuBiuင(:ခင(3


Collection Interfaces
Methods of Collection
Type Method Return Type
General size() Int
isEmpty() boolean
contains(Object) boolean
iterator() Iterator<E>
toArray() Object []
toArray(T[])<T> T []
containsAll(Collection<?>) boolean
retainAll(Collection<?>) boolean
Add and Remove add(E) boolean
remove(Object) boolean
addAll(Collection<? extends E>) boolean
Methods of Collection
Type Method Return Type
Add and Remove removeAll(Collection<?>) boolean
removeIf(Predicate<? super E>) boolean
clear() boolean
Default Method spliterator() Spliterator<E>
stream() Stream<E>
parallelStream() Stream<E>
General Implementations
Hash Table +
Interface Hash Table Resizable Array Balanced Tree Linked List
Linked List

Set HashSet TreeSet LinkedHashSet

List ArrayList LinkedList

Deque ArrayDeque LinkedList

Map HashMap TreeMap LinkedHashMap


HashTable
• Key BDင(7 Value တiuအ23
Map လuပ(eပ3Biuင(eသ2
Data Structure

• Hash Function အ23


အသu93:ပu၍ Array ၏
Index ကiu တ,က(ခ/က(eပ3
Biuင(
Resizable Array
• Array သည( Element မ/23
အ23 အစAအစP(အလiuက(
န9ပFတ(တပ(၍ သiမ(3ဆည(3
eပ3Biuင(

• Array သည( Fix Size

• Resizable Array သည(


Variable Size Array
Balance Tree

• Tree ပu9စ9 Data ဖ,C7စည(3ပu9ကiu


အသu93:ပuထ23

• Balanced Tree သည(


Element မ/23၏ တန(ဖiu3:ဖင(7
အစAအစP(အ23 ခ/ထ23eပ3Biuင(
Linked List

• Element တiu၏ အစAအစP(အ23 eဖ2(:ပရန( Node အစuအစည(3

• အ"iu3အIင(3ဆu93 Data ဖ,C7စည(3ပu9

• Node တiuတ,င( ၎င(3တiu၏ Value BDင(7 ခ/iတ(ဆက(လ/က(Iieသ2


eန2က(ဘက(Ii Node အ23 eဖ2(:ပBiuင(eသ2 အခ/က(အလက(
ကiu သiမ(3ဆည(3ထ23
Set Interface
• Set Interface သည( သခS/2ဘ2သ2ရပ(၏ အစuအ23 ကiuယ(စ23:ပueသ2 Interface :ဖစ(၏

• Set အတ,င(3 Element အမ/iu3တLမ/23အ23 တစ(ခuထက(ပiuTပA3 ထ6(7ထ23၍မရပF

• Set အတ,င(3Ii Element မ/23၏ အစAအစP(အ23 ထiမ(3မထ23Biuင(ပF

• General Implementation အ:ဖစ(eရ3သ23ထ23eသ2 Concrete Class မ/23မD2


eအ2က(ပFအတiuင(3 :ဖစ(၏။

• java.util.HashSet (Performance အeက2င(3ဆu93)

• java.util.TreeSet (Element အ23 @ကA3စP(ငယ(လiuက(စAeပ3Biuင()

• java.util.LinkHashSet (ထ6(7သ,င(3ထ23eသ2 အစAအစP(အ23 မDတ(eပ3Biuင()


Sample Codes
public static void main(String[] args) {
Set<Integer> hashSet = new HashSet<>();
Set<Integer> treeSet = new TreeSet<>();
Set<Integer> linkSet = new LinkedHashSet<>();
for (int i=10; i > 0; i--) {
hashSet.add(i);
treeSet.add(i);
linkSet.add(i);
}
System.out.println("HashSet : " + hashSet);
System.out.println("TreeSet : " + treeSet);
System.out.println("LinkedHashSet : " + linkSet);
}
List Interface
• Element မ/23အ23 အစAအစP(အလiuက( သiမ(3ဆည(3ထ23Biuင(TပA3
Sequence ဟuလည(3 eခWသည(

• Set BDင(7 မတLပC Duplicate :ဖစ(eနeသ2 Element မ/23ကiuပF


သiမ(3ထ23eပ3Biuင(

• General Purpose Implementation Class မ/23မD2

• java.util.ArrayList

• java.util.LinkedList
Sample Codes
public class ListSample {

static String [] DATA = {"Aung", "Maung", "Bo", "Jo"};

public static void main(String[] args) {


List<String> arrayList = new ArrayList<String>(Arrays.asList(DATA));

List<String> linkList = new LinkedList<String>();


linkList.addAll(arrayList);

showData(arrayList);
showData(linkList);
}

// show data method


}
ArrayList & LinkedList
ArrayList BDင(7 LinkedList တiuသည( Data ဖ,C7စည(3ပu9မD2 မတLညAeသ2eHက2င(7 အ23သ2ခ/က(

အ23နည(3ခ/က(မ/23မD2လည(3 မတLညAHကeပ

အeနအထ%&မ(%& ArrayList LinkedList

Index :ဖင(7 Element အ23I2:ခင(3 eက2င(3မ,န(

Add BDင(7 Update eက2င(3မ,န(

Remove eက2င(3မ,န(

Memory အသu93:ပuပu9 eက2င(3မ,န(


General Methods
Type Method Return Type
Access get (int index) E
Add and Remove Set (int index, E element) void
add (E element) boolean
add (int index, E element) void
remove(int index) E
addAll(int index, Collection<? extends E> c) boolean

Search indexOf(Object o) Int


lastIndexOf(Object o) Int
Iteration listIterator() ListIterator<E>
listIterator(int index) ListIterator<E>
rangeOfView subList(int from, int to) List<E>
Queue
• Queue အ23အသu93:ပu၍ မည(သ6(7 Element အ23 ဦ3စ23eပ3 အသu93:ပuမည(ဆiuသည(ကiu
သတ(မDတ(Biuင(

• Collection ၏ Method မ/23အ:ပင( Queue တ,င(ပFဝင(eသ2 သA3:ခ23 Method မ/23


လည(3Ii၏

• မ/23eသ2အ23:ဖင(7 Queue မ/23တ,င( Null တန(ဖiu3အ23 ထ6(7သ,င(3၍ မရ

• အခ/iueသ2 Queue မ/23မDလ,C၍ Queue မ/23သည( Fist In First Out ပu9စ9ကiu အသu93:ပu

• General Purpose Implementation Method မ/23မD2

• LinkedList

• PriorityQueue
Sample Code
public class QueueSample {

public static void main(String[] args) throws


InterruptedException {

Queue<Integer> queue = new LinkedList<Integer>();

for(int i=0; i < 10; i++) {


queue.offer(i);
}

while(!queue.isEmpty()) {
System.out.println(queue.poll());
Thread.sleep(1000);
}
}
}
Deque
• အဆu93BDစ(ဘက(ပFeသ2 Queue မ/23:ဖစ(Hကသည(

• Queue eရ2 Stack ၏ အရည(အeသ,3မ/23ကiu ပiuင(ဆiuင(

• အစပiuင(3eက2 အဆu93ပiuင(3Ii Element မ/23အ23 ဆက(သ,ယ(Biuင(

• First In First Out eက2 Last In First Out ပu9စ9ကiu အသu93:ပuBiuင(

• General Purpose Implementation Class

• ArrayDeque

• LinkedList
Methods of Deque
Type Method Return Type
Add addFirst(E element) void
addLast(E element)
offerFirst(E element) boolean
offerLast(E element)
Remove removeFirst() E
removeLast()
pollFirst() E
pollLast()
removeFirstOccurrence(Object o) boolean
removeLastOccurrence(Object o)
Examine getFirst() E
getLast()
peekFirst() E
peekLast()
Sample Codes
public class DequeSample {
public static void main(String[] args) throws InterruptedException {
Deque<Integer> dq = new ArrayDeque<Integer>();

for(int i=0; i < 10; i++) {


if(i%2 == 0)
dq.addFirst(i);
else
dq.addLast(i);
}
while(!dq.isEmpty()) {
System.out.println(dq.removeLast());
Thread.sleep(1000);
}
}
}
Map
• သခS/2ဘ2သ2ရပ(၏ Function အ23 eမ2(ဒယ(ယLထ23eသ2 Interface

• Key မ/23BDင(7 Value မ/23အ23 Map လuပ(၍ Element မ/23အ23 ထiမ(3သiမ(3ထ23


သည(

• Map ၏ Key မ/23သည( Duplicate မ:ဖစ(ပF

• Key တစ(ခuသည( Value တစ(ခuကiuသ2 Map လuပ(Biuင(ပFသည(

• General Purpose Implementation Class မ/23မD2

• HashMap

• TreeMap
Method of Map
Type Method Return Type
Basic Operation put(K key, V value)
 V
get(k key)

remove(V v)
containsKey(K k)
 boolean
containsValue(V v)

isEmpty()
size() int
Bulk Operation putAll(Map<k,V> map)
 void
clear()
Collection Views keyset() Set<K>
values() Collection<V>
entrySet() Set<Map.Entry<K,V>
Sample Code
public class MapSample {
static String [] DATA = { "Naung", "Aung", "Maung"};
public static void main(String[] args) {
Map<Integer, String> hashMap = new HashMap<>();
Map<Integer, String> treeMap = new TreeMap<>();

for(int i=DATA.length; i > 0;) {


hashMap.put(--i, DATA[i]);
}

treeMap.putAll(hashMap);

System.out.println(hashMap);
System.out.println(treeMap);
}
}
Arrays Utility Class
• Array မ/23အ23 အသu93:ပuရ2တ,င( အသu93ဝင(eသ2 လuပ(eဆ2င(ခ/က(မ/23အ23
စuစည(3ထ23eသ2 Utility Class

• Arrays :ဖင(7 လuပ(eဆ2င(Biuင(eသ2 လuပ(eဆ2င(ခ/က(မ/23မD2

• Sorting

• Searching (Binary Search)

• Filling

• Equals

• Copying
Sorting Methods
Method Description
static void sort(Object [] array) အ:ခ23eသ2 Parameter မ/23 မပFဝင(ပFက @ကA3ရ2သiu စAစP(သ,23

မည(:ဖစ(TပA3၊ အသu93:ပuသ6(7 အလဂiuရAဇင(မD2 Quick Sort :ဖစ(၏။

static <T> void sort( Comparator အ23 အသu93:ပu:ခင(3အ23:ဖင(7 ကiန(3စP(အတ,င(3Ii


T [] t,
Object မ/23အ23 BDစ(သက(သလiu e:ပ2င(3လည(3 စAစP( (sort) Biuင(
Comparator<? super T> c)
ပFသည(။
static void sort(Object[] a, ကiန(3စP(အတ,င(3Ii အခ/က(အလက(မ/23ကiuလည(3 အစန9ပFတ(BDင(7
int fromIndex,
အဆu93န9ပFတ(ကiu အသu93:ပuက2 အစiတ(အပiuင(3တစ(ခuတည(3ကiuလည(3
int toIndex)
  :ပန(လည(စAစP( Biuင(၏။
static void sort(T[] a,
int fromIndex,
int toIndex,
Comparator<? super T> c)
Sorting Sample
public class SortingSample {

public static void main(String[] args) {


String [] array = {"Maung", "Aung", "Shwe Ba"};
print("Before Sort", array);
Arrays.sort(array);
print("After Sort", array);
}

static void print(String m, String [] array) {


System.out.println(m);
for(String str : array)
System.out.println(str);
}
}
Searching Methods
Method Description
static int binarySearch ( Array အတ,င(3မD key တန(ဖiu3အ23 I2eဖ,ပFမည(။ eတ,7Iieသ2
Object [] a,
Object key) index အ23 ရလဒ(အ:ဖစ(:ပန(eပ3မည(။ မeတ,7IiပFက အB\တ(

တန(ဖiu3အ23 :ပန(eပ3မည(။
static int binarySearch ( Array ၏ fromIndex မD toIndes အတ,င(3မD key တန(ဖiu3
Object [] a, int fromIndex,
int toIndex, အ23 I2eဖ,ပFမည(။ eတ,7Iieသ2 index အ23 ရလဒ(အ:ဖစ(:ပန(
Object key)
eပ3မည(။ မeတ,7IiပFက အB\တ(တန(ဖiu3အ23 :ပန(eပ3မည(။

static <T> int binarySearch( Generics Type Array အတ,င(3မD key အ23 I2eဖ,ရ2တ,င(
T[] a,
T key, အသu93:ပuပFသည(။
Comparator<? super T> c)
Searching Sample
public class SearchingSample {

public static void main(String[] args) {


String [] array = {"Maung", "Aung",
"Shwe Ba", "Ma Oo", "Nyi Nyi",
"Ei Ei", "Thwe Thwe"};

Arrays.sort(array);

int index = Arrays.binarySearch(array, "Nyi Nyi");


if(index >= 0) {
System.out.format("%s has found at %d%n", "Nyi Nyi", index);
} else {
System.out.format("%s has not found", "Nyi Nyi");
}
}
}
Other Methods
Method Description
static void fill(Object[] a, Object val)  Arrays#fill လuပ(eဆ2င(ခ/က(သည( ကiန(3စP(အတ,င(3Ii အခ/က(အလက(မ/23

static void fill(Object[] a, အ23 val ၏ တန(ဖiu3:ဖင(7 အစ23ထiu3Biuင(မည( :ဖစ(ပFသည(။ တဖန( int
int fromindex,
fromindex, int toindex ပFရ2မAတ2မ/23 ပFဝင(သ6(7 လuပ(eဆ2င(ခ/က(ကiu
int toindex,
Object val) အသu93:ပuပFက ကiန(3စP(အတ,င(3Ii အခ/က(အလက(မ/23အ23 eနရ2သတ(မDတ(၍

အစ23ထiu3Biuင(မည( :ဖစ(ပFသည(။
static boolean equals(Object[] a, ကiန(3စP(တစ(ခuBDင(7 တစ(ခu တLညAeHက2င(3အ23 စမ(3သပ(ရ2တ,င( အသu93:ပuBiuင(
Object[] a2)
ပFသည(။ တLညAပFက true ကiu ရလဒ(အ:ဖစ( ရIiမည(:ဖစ(TပA3၊ မတLညAပFက

false ကiu ရIiမည( :ဖစ(ပFသည(။


static <T> T[] copyOf(T[] original, ကiန(3စP(တစ(ခuမD အeရအတ,က(အ23 သတ(မDတ(၍ eက2(ပAကLBiuင(မည(:ဖစ(TပA3၊
int newLength) 
အeရအတ,က(သည( မ\ရင(3ကiန(3စP(Ii အeရ3အတ,က(ထက(နည(3eနပFက ပiu
static <T> T[] copyOfRange(T[] original,
eနသည(မ/23ကiu :ဖတ(ထuတ(မည(:ဖစ(TပA3၊ မ/23eနပFက လiuအပ(သည(မ/23ကiu
int from,
int to) null :ဖင(7 :ဖ6(7စ,က(၍ eက2(ပAကL3မည( :ဖစ(ပFသည(။


copyOfRange အ23 အသu93:ပuပFက အစeနရ2BDင(7 အဆu93eနရ2အ23

သတ(မDတ(၍ eက2(ပAကL3Biuင(မည( :ဖစ(သည(။


Copying Array
public class CopyingSample {
public static void main(String[] args) {
String [] array = {"Maung", "Aung",
"Shwe Ba", "Ma Oo", "Nyi Nyi",
"Ei Ei", "Thwe Thwe"};

String [] copy = Arrays.copyOf(array, 3);

for(String s : copy)
System.out.println(s);
}
}
Sorting Objects
• Arrays BDင(7 Collection တiuထCမD2IiတC7 Element eတ,ကiu Arrays BC7
Collections Utilities Class eတ,ကiu သu93TပA3 Sort လuပ(လiuရပFတယ(

• Sort လuပ(တC7 eနရ2မD2 Element eတ,ဟ2 Sort လuပ(လiuရတC7


Object eတ,:ဖစ(မယ(၊ ဒFမDမဟuတ( Object တစ(ခuBC7 တစ(ခu ဘယ(လiu
BDiuင(3ယDဥ(ရမယ(ဆiuတ2ကiu eဖW:ပeပ3Biuင(တC7 Comparater လiuအပ(ပF
တယ(

• Sort လuပ(လiuရတC7 Object eတ,ကeတ27 Primitive Type eတ,နC7


Comparable Interface ကiu Implement လuပ(ထ23တC7 Object
eတ,ပFပC
Item Class
public class Item implements Comparable<Item> {
private String name;
private double price;
// getter, setter, Constructor
@Override
public String toString() {
return String.format("Name : %s, Price : %f", name, price);
}
@Override
public int compareTo(Item o) {
int result = name.compareTo(o.name);
if(result == 0) {
return (new Double(price - o.getPrice())).intValue();
}
return result;
}
}
TestData
public class TestData {

public static List<Item> getItems() {


return Arrays.asList(new Item("Tea", 200.00),
new Item("Coffee", 220.00),
new Item("Ice Tea", 220.00),
new Item("Ice Coffee", 220.00),
new Item("Domino", 1500.00),
new Item("Farludar", 1200.00)
);
}
}
Sorting Custom Object
public class SortSample {

public static void main(String[] args) {


List<Item> items = TestData.getItems();

System.out.println(items);

Collections.sort(items);

System.out.println(items);
}
}
Shuffling
public class ShufflingSample {

public static void main(String[] args) {


List<Item> list = TestData.getItems();

System.out.println(list);
Collections.shuffle(list);

System.out.println(list);
}
}
Searching
public static void main(String[] args) {
List<Item> list = TestData.getItems();

Collections.sort(list);
Item tea = new Item("Tea", 200.00);
int result = Collections.binarySearch(list, tea);

if(result >= 0)
System.out.printf("%s has found at %d%n",
tea.getName(), result);
else
System.out.printf("%s has not found in List%n",
tea.getName(), result);
}
ဖ,C7စည(3ပu9အ23သiIieစBiuင(eသ2 Method မ/23

• Collections ၏ frequency BDင(7 disjoint အလဂiuရAဇင(


မ/23သည( Collection မ/23၏ ဖ,C7စည(3ပu9ကiu သiIiနiuင(eသ2
လuပ(eဆ2င(ခ/က(မ/23 :ဖစ(Hကသည(။

• Collections#frequency သည( Collection တစ(ခuအတ,င(3


Object တစ(ခuသည( အ@ကiမ(မည(မ^ပFဝင(သည(ကiu သiIiနiuင(
မည( :ဖစ(သည(။

• တဖန( disjoint လuပ(eဆ2င(ခ/က(သည( Collection BDစ(ခu


အတ,င(3 ပတ(သက(မ\7 IiမIi သiIiနiuင(မည( :ဖစ(သည(။
Special Usages

Singleton Unmodifiable Synchronization


Unmodifiable
Method Return Type

unmodifiableCollection (Collection<T> c) Collection<T>

unmodifiableList(List<T> list) List<T>

unmodifiableMap(Map<K,V> map) Map<K, V>

unmodifiableSet(Set<T> set) Set<T>

unmodifiableSortedMap(SortedMap<K,V> map) SortedMap<K,V>

unmodifiablSortedeSet(SortedSet<T> set) SortedSet<T>


Synchronize
Method Return Type
synchronizedCollection (Collection<T> c) Collection<T>
synchronizedList(List<T> list) List<T>
synchronizedMap(Map<K,V> map) Map<K, V>
synchronizedSet(Set<T> set) Set<T>
synchronizedSortedMap(SortedMap<K,V> map) SortedMap<K,V>
synchronizedlSortedeSet(SortedSet<T> set) SortedSet<T>
Thread Worker
public class ThreadWorker extends Thread{
private List<?> list;
public static int total = 0;
public ThreadWorker(final List<?> list) {
super();
this.list = list;
}
@Override
public void run() {
int count = 0;
while(list.remove(null))
count ++;
System.out.format("Consume %d count%n", count);
synchronized (this.getClass()) {
total += count;
}
}
}
Non Thread Safe
public class NonThreadSafeSample {
public static void main(String[] args) throws InterruptedException {
List<?> list = new LinkedList<>();
for(int i= 0; i < 100000; i++)
list.add(null);

List<Thread> threads = new LinkedList<>();


for(int i=0; i < 5; i++)
threads.add(new ThreadWorker(list));

for(Thread t : threads)
t.start();

for(Thread o : threads)
o.join();

System.out.format("Total is %d%n", ThreadWorker.total);


}
}
Thread Safe
public class ThreadSafeSample {
public static void main(String[] args) throws InterruptedException {
List<?> list = Collections.synchronizedList(new LinkedList<>());
for(int i= 0; i < 100000; i++)
list.add(null);

List<Thread> threads = new LinkedList<>();


for(int i=0; i < 5; i++)
threads.add(new ThreadWorker(list));

for(Thread t : threads)
t.start();

for(Thread o : threads)
o.join();

System.out.format("Total is %d%n", ThreadWorker.total);


}
}
Other Methods
အမည* +င*&လင*&ခ(က*
reverse Collectionအတ,င(3Ii Element မ/23၏ အစAအစP(အ23 e:ပ2င(3:ပန( :ပန(TပA3 စAစP(

ရ2တ,င( အသu93:ပuBiuင(eသ2လuပ(eဆ2င(ခ/က( တစ(ခu:ဖစ(ပFသည(။


fill List တစ(ခuအတ,င(3Ii Element မ/23အ23 Object တစ(ခu:ဖင(7 အစ23ထiu3Biuင(၏။ ဤ

လuပ(eဆ2င(ခ/က(သည( List တစ(ခuအ23 :ပန(လည( Initialize လuပ(ရ2တ,င( အသu93ဝင(မည(

:ဖစ(ပFသည(။
copy List တစ(ခuမD အ:ခ23eသ2 List တစ(ခuဆAသiu eက2(ပAကL3ရ2တ,င( အသu93:ပuBiuင(ပFသည(။

Argument အeန:ဖင(7List BDစ(ခuကiu လiuအပ(မည( :ဖစ(ပFသည(။ eက2(ပA List BDင(7 မ\ရင(3

List တiu:ဖစ(Hက၏။ eက2(ပA List ၏ size သည( အနည(3ဆu93 မ\ရင(3 List eလ2က(Iiရန(

လiuအပ(ပFသည(။ မ\ရင(3 List ပမ2နထက( ပiuမ/23သ,23ပFက ပiueသ2 eနရ2မ/23အ23 အက/iu3

သက(eရ2က(မ\7 Iiမည( မဟuတ(eပ။


Other Methods
အမည* +င*&လင*&ခ(က*
swap List တစ(ခuအတ,င(3Ii Element မ/23အ23 eနရ2e:ပ2င(3ရ2တ,င( အသu93:ပuBiuင(မည( :ဖစ(

ပFသည(။ ပ`မ Argument မD2 List Object :ဖစ(TပA3၊ eန2က( Argument BDစ(ခuမD2

e:ပ2င(3လiuသ6(7 eနရ2 (index) မ/23 :ဖစ(Hကသည(။ အကယ(၍ e:ပ2င(3e"a7လiueသ2 eနရ2

BDစ(ခuသည( List ၏ size ထက(မ/23eနပFက IndexOutOfBoundException ကiu :ဖစ(eပW

eစမည( :ဖစ(၏။
addAll addAll လuပ(eဆ2င(ခ/က(သည( Collection တစ(ခuအတ,င(3ကiu၊ ဒuတiယ Argument :ဖစ(

eသ2 Varargs အတ,င(3မD Object မ/23အ23 တစ(Tပiuင(နက(တည(3 ထ6(7သ,င(3Biuင(မည( :ဖစ(

ပFသည(။ 
max Collectionအတ,င(3Ii သဘ2ဝအစAအစP( အတiuင(3စAစP(eသ2အခF အ@ကA3မ23ဆu93 Element

ကiu ရIiမည( :ဖစ(ပFသည(။


min Collection အတ,င(3Ii သဘ2ဝအစAအစP( အတiuင(3 စAစP(eသ2အခFအeသ3ငယ(ဆu93

Element ကiu ရIiမည( :ဖစ(သည(။

You might also like