Map Java Collection Tutorial

Map Stores values in key and value. map does not allow duplicate key. only one null key but any number of null values To synchronize the Map use. Collections.synchronizedMap(yourMapObject) Hashmap Hashmap allows random storage sequence is not maintained. Stores values in key and value. Hashmap is not synchronized. Collections.synchronizedHashset Hashmap does not allow duplicate key. Hashmap allows only one null…

Read More Read More

Java Collection -Set

<I>Set does not contain duplicates. randomly stores elements. does not permits null elements. How to make your list synchronised? Collections.synchronizedSet(yourSetObject) Classes  <C>TreeSet Sorts element by natural order. rest of the properties are same as specified by interface Set Internally it is implemented using the TreeMap.        Main purpose is for sorting the stores elements.        …

Read More Read More

Files Read by Multiple Thread

How to read each file on separate thread. Step 1:Get List of all files in the specified folder

    Step 2:Create Class which will display contents of file and implements runnable. Note that I have created constructor to pass the filelocation to the thread,

  Now read file logic will only read contents of file using java8…

Read More Read More

Binary Search Example

Binary search example in java

 

TreeSet Vs HashSet

Treeset and hashset both belong to set and obey the rule of maintaining uinique elements . But treeset comes with some more added advantage. TreeSet gives ability to sort elements with the help of the compareTo(). More examples on http://www.shivapreals.tech/allpost/java-tutorial/java-collection-tutorial/ HashSet allows null elements. Treeset never allows null.   Hashset is faster as it is not dealing with sorting of elements. Treeset has sorting capability so it is somewhat slow.   To compare equality hashSet uses equals() while on…

Read More Read More

Java Jdbc Tutorial with H2

JDBC is built for the purpose of communication with relational databases with the help of Java Program. The Jdbc Driver is component that comes like mediator that takes to and fro data from java to database and vice versa. Today We are going to perform save ,delete, display operations on H2 database from java program. Before we kick start our…

Read More Read More

Anonymous classes in java

Type2:

 

Test Multiple Read By threads in java

 

StringBuffer vs StringBuilder example

StringBuffer and StringBuilder are widely used to manipulate the strings in java. StringBuffer StringBuffer basically used for modifying String If we have String then why we should again learn this new class? Because String is immutable each modification on String creates new Object while in StringBuffer it is mutable when you modify contents of StringBuffer it does not create new…

Read More Read More

Java Mutithreading

Why we need multithreading in java I am going to explain in most simple easy way. Imagine google is giving you data in seconds literally 1000’s of links are fetched in less than a second.How this damn thing is possible.Let us take one example if you and your cousin is at home you are told to make the lunch at…

Read More Read More