Java

Exploring some interesting stuffs in java.

Java

Hashing

Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string. For example SHA-2 Hash of above statement will be 696421ad8a148a5e4c4064b9c9191831b6bed4aa484b2ccebe3208184bb30b29 Check Online at xorbin.com Other hashing are MD5 and SHA-1 (previous version of SHA – 2). Importance of Hashing Functions can be judged […]

Read More
Featured
Java

WeakReference and WeakHashMap in Java

Weak Reference : An Object will not be garbage collected if one or more reference exits. This is not true always if the references are Weak Reference then its a valid candidate of Garbage Collection. four types of references in Java i.e. strong reference, soft reference, weak reference and phantom reference. We will discuss about […]

Read More
Java

JAVA 7 Features

Key Features Strings in switch Statement Multiple Exception Handling Try with Resources Java nio Package Binary Literals, underscore in literals Diamond Syntax Many others refer to Oracle Release note JAVA 7 : Code named Dolphin and released on July 28, 2011. Release Note Oracle Release Note Feature Page Support of String in Switch Case. String in […]

Read More
Featured
Java

Native Keyword / Calling C Program From Java

You might have seen in Java API many methods are using native keyword. Lets understand them. The native keyword is applied to a method to indicate that the method is implemented in native code using JNI. Definition From JSR A method that is native is implemented in platform-dependent code, typically written in another programming language […]

Read More
Featured
Java

Ant Build Tool : Quick Notes

Ant Script for JAVA Developers 1) Simple Ant Script for Clean , Compile and jar generation adding Manifest information to jar init called .. Delete All Class Files .. Delete All Jar Files .. Compile All Java Files .. Generate Jar File .. Note :- All folder path are relative to basedir . Here is […]

Read More
Featured
Java

Blank final field in Java

A variable that is declared as final and not initialized is called a blank final variable. A blank final variable forces the constructors to initialize it. In other words The final property of class must have a value assigned before object is created. So the last point where you can assign value to them is […]

Read More
Featured
Java

Fail Fast vs Fail Safe Iterator in Java

When an iterator is created, either it is directly created on the collection (Fail Fast), or created on a clone of that collection (Fail Safe).This brings below two types of Iterator. Fail Fast : As name suggest fail-fast Iterators fail as soon as they realized that structure of Collection has been modified since iteration has […]

Read More
Featured
Java

Double Brace Initialization In Java

Another way of initializing collections and objects in Java. This is rarely known concept of Java,although this type of initialization has been with java from many years. The technique/concept is called Double Brace Initialization technique in Java. Lets start with an example. Using ArrayList in java (Normal way) List languages = new ArrayList(); languages.add(“English”); languages.add(“Hindi”); languages.add(“German”); Double […]

Read More
Featured
Java

JVM Shutdown Hook

As the name specifies its a Hook provided by JVM to register a Thread when it shut down. i.e. piece of instructions that JVM should execute before going down. How To Achieve The java.lang.Runtime.addShutdownHook(Thread hook) method registers a new virtual-machine shutdown hook. When to Use To release critical resources in the event of unexpected JVM […]

Read More
Featured
Java

Use of Robot Class

Programming in Java doesn’t have to be dull and boring. In fact, it’s possible to have lots of fun while programming in Java. Lets use the Robot class to write programs that are both fun and useful. Added in JDK v 1.3 . As Per Sun (now Oracle): “This class is used to generate native […]

Read More