imsavva.com

Folder icon

Coding

Describing the Java Map collection. Difference between other collections.

showPostImage(564019001)

Uncaught exception: the image is currently being shown in a museum

Map is a collection that stores key-value pairs. A map cannot contain duplicate keys. What is the main difference between Map and other collections? The main difference between Map and other collections is that it contains key and value. It doesn’t inherit from Collection interface. The Map interface includes methods…
Posted on
2016-03-19

Describing the Java List collection interface

showPostImage(575624130)

Uncaught exception: the image was stolen by a UFO

List is an ordered collection that can contain duplicates. In addition to the Collection interface methods, the List interface includes the following: Positional access: manipulating the elements by their index in the list. This includes methods such as: get, set, add, addAll, remove. Search: methods indexOf and…
Posted on
2016-03-19

Describing the Java Deque collection interface

A Deque is a double-ended-queue. It is a collection of elements that supports the insertion and removal of elements at both end points. It implements both Stack and Queue at the same time. This interface defines following methods: void addFirst(E e) void addLast(E e) boolean offerFirst(E e) boolean offerLast(E e) E…
Posted on
2016-03-19

Can I use try-finally block (without catch)?

showPostImage(597176531)

Uncaught exception: the image is currently being shown in a museum

Yes, you can use the try-finally construction. As a use case, we can try to connect to a database and finally we will close the connection: This code looks a bit redundant. But in Java 7 we can use a try-with-resources block to handle our resources closing in a more convinient way... In Java 7 we can use a try-with…
Posted on
2016-03-19

JavaScript scope mini-task

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…
Posted on
2016-02-19

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…
Posted on
2015-07-14

Object initialization order

showPostImage(-1685463569)

Uncaught exception: the image is currently being shown in a museum

If you don't know how objects initialize in Java, it may be a surprise when you write some code. Click more to see Java object initialization order and an example. The initialization order is: Parent static initialize block Parent static field Child static field Child static initialize block Parent instance initialize…
Posted on
2015-06-29