Java Reflection: class "Method" to inovoke methods and get metadata

Posted on Sat 28 December 2013 in Java • Tagged with Java, Programming

Java Logo

using [java.lang.reflect.Method]{style="font-family: courier new,courier;"} you can get metadata/signature of methods (including private) and can invoke accessible methods at runtime.

Class Method provides a great tool to list all methods and find information about methods.  following tutorial will provide you more detail of class …


Continue reading

Java 7 : Try-with-resources - Close resources automatically with AutoCloseable interface

Posted on Sun 15 December 2013 in Java • Tagged with Java

Every time we write code with FileInputStream,

BufferReader

  etc. we need to close those resource explicitly in finally block.

Now from Java 7, there are two interfaces included

Closeable

and

AutoCloseable

with single abstract method

close(),

  which enables implementing class to close resources aromatically after try block.

Lets see how …


Continue reading

Java 7: Binary literal type

Posted on Sun 15 December 2013 in Java • Tagged with Java

From Java 7 Binary type also joins the category of literal with *

byte, short, int and long

. Which means a binary value can be assigned  by using 0b or 0B  *prefix to a  primitive type.

What is a Literal :  A literal is source code representation of source code. Which can …


Continue reading