Fun with Static import

 

Static import is another interesting feature in java.

We write,  System.out.println() method thousands of time during java coding.

if you are lazy like me and don’t like to write Sysem.out.println a lot of times, use my code.


package com.codexplo.utils;

public class Utils {
public static void p(Object o) {
System.out.print(o);
}

public static void pln(Object o) {
System.out.println(o);
}
}

and to use this code.. you  need static import .. like

To know more about static import: http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s