Whas is a collection?
Collection is an object that groups multiple elements into a single unit. Collections are used to store, retrieve and manipulate data. Live example: several Employee objects can be grouped into a collection: Java has a Java Collection Framework (JCF), which consists of: Interfaces - these are abstract data types that…
What benefits does JCF provide?
Java Collections Framework provides the following benefits: Reduces programming effort: you don’t need to invent the wheel anymore, JCF provides useful data structures and algorithms. Increases program speed and quality: JCF provides high-performance, high-quality implementations of useful data structures and…
What is a diamond operator?
This is an improvement appeared in Java 7. Consider you have a class with a long name and you need to create a HashMap of Strings and Lists of your class instances. You code will look like this: In Java 7 you can write less code using the diamond operator(< > ):
What data can be stored in a collection?
You can store anything but primitives. To store primitives consider using wrappers (Integer for int, Double for double, etc…). For example, you can store your own classes: To store primitives: Notice, that you can add primitives, since it will be wrapped automatically:
What methods does Java Collection interface contain?
int size(); boolean isEmpty(); boolean contains(Object o); Iterator iterator(); Object [ ] toArray(); T [ ] toArray(T [ ] a); boolean add(E e); boolean remove(Object o); boolean containsAll(Collection<?> c); boolean addAll(Collection<? extends E> c); boolean removeAll(Collection<?> c); boolean retainAll(Collection…
What we will see in the console? The result will be: In the outer function this refers to the object, because the outer func is invoked as a method. But the inner function is invoked as a usual function, and hence this refers to window object. However, the inner function still can see its parent's scope, that's…
Some daily news
There are some interesting things in my life today. I started learning English again, and I finished one of my interesting tasks. Today, 14 June 2015, I started learning English at the office, where I'm studying Java. I have lessons every Tuesday and Thursday. Also I'm going to continue taking personal lessons in my…