<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: What is a static import in java?</title>
	<atom:link href="http://javapapers.com/core-java/what-is-a-static-import-in-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://javapapers.com/core-java/what-is-a-static-import-in-java/</link>
	<description>BLOG on core java, servlets, JSP, design patterns interview questions with quality answers, source code and discussions.</description>
	<lastBuildDate>Fri, 30 Jul 2010 10:43:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Priya</title>
		<link>http://javapapers.com/core-java/what-is-a-static-import-in-java/comment-page-1/#comment-1756</link>
		<dc:creator>Priya</dc:creator>
		<pubDate>Fri, 16 Jul 2010 18:55:24 +0000</pubDate>
		<guid isPermaLink="false">http://javapapers.com/?p=65#comment-1756</guid>
		<description>Static import in java is new for me. I have never heard about it. Thanks man.</description>
		<content:encoded><![CDATA[<p>Static import in java is new for me. I have never heard about it. Thanks man.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: krunal shah</title>
		<link>http://javapapers.com/core-java/what-is-a-static-import-in-java/comment-page-1/#comment-1478</link>
		<dc:creator>krunal shah</dc:creator>
		<pubDate>Thu, 10 Jun 2010 05:32:18 +0000</pubDate>
		<guid isPermaLink="false">http://javapapers.com/?p=65#comment-1478</guid>
		<description>Thanx for explaining in such a simple manner.

----- krunal shah</description>
		<content:encoded><![CDATA[<p>Thanx for explaining in such a simple manner.</p>
<p>&#8212;&#8211; krunal shah</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashant Reddy</title>
		<link>http://javapapers.com/core-java/what-is-a-static-import-in-java/comment-page-1/#comment-1179</link>
		<dc:creator>Prashant Reddy</dc:creator>
		<pubDate>Mon, 12 Apr 2010 05:00:37 +0000</pubDate>
		<guid isPermaLink="false">http://javapapers.com/?p=65#comment-1179</guid>
		<description>Hi,

   This information on java static import is very good..</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>   This information on java static import is very good..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bizz</title>
		<link>http://javapapers.com/core-java/what-is-a-static-import-in-java/comment-page-1/#comment-768</link>
		<dc:creator>Bizz</dc:creator>
		<pubDate>Fri, 22 Jan 2010 10:14:53 +0000</pubDate>
		<guid isPermaLink="false">http://javapapers.com/?p=65#comment-768</guid>
		<description>Hi,

I happened to see your post on &quot;Static import in Java&quot; and find it quite informative. 
Thanks for sharing valuable knowmledge.
Bizz..</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I happened to see your post on &#8220;Static import in Java&#8221; and find it quite informative.<br />
Thanks for sharing valuable knowmledge.<br />
Bizz..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://javapapers.com/core-java/what-is-a-static-import-in-java/comment-page-1/#comment-284</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Tue, 17 Nov 2009 23:23:35 +0000</pubDate>
		<guid isPermaLink="false">http://javapapers.com/?p=65#comment-284</guid>
		<description>Yes that is right. Avoid using java static import in general straight forward cases.

But consider using the java static import in following two scenarios:

1) When you have to only one or max two static imports in a class many number(say atleast 20) of times.
2) Constant Interface Antipattern

Example for above case 2):
When you create a interface with constants and extend it to use (note below &#039;PI&#039; referring the constant). In this scenario, better use the bottom code.

public interface MyConstant {
	public static final double PI = 3.14159;
}
 
public class MyMath implements MyConstant { 
	public double myComplexMathMethod() {
		return (PI * 100);
	}
}

--------------

public final class MyConstant {
	private MyConstant() {}
	public static final double PI = 3.14159;
}

import static MyConstant.PI;
public class MyMath { 
	public double myComplexMathMethod() {
		return (PI * 100);
	}
}

http://en.wikipedia.org/wiki/Constant_interface - has good information related to the topic.</description>
		<content:encoded><![CDATA[<p>Yes that is right. Avoid using java static import in general straight forward cases.</p>
<p>But consider using the java static import in following two scenarios:</p>
<p>1) When you have to only one or max two static imports in a class many number(say atleast 20) of times.<br />
2) Constant Interface Antipattern</p>
<p>Example for above case 2):<br />
When you create a interface with constants and extend it to use (note below &#8216;PI&#8217; referring the constant). In this scenario, better use the bottom code.</p>
<p>public interface MyConstant {<br />
	public static final double PI = 3.14159;<br />
}</p>
<p>public class MyMath implements MyConstant {<br />
	public double myComplexMathMethod() {<br />
		return (PI * 100);<br />
	}<br />
}</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>public final class MyConstant {<br />
	private MyConstant() {}<br />
	public static final double PI = 3.14159;<br />
}</p>
<p>import static MyConstant.PI;<br />
public class MyMath {<br />
	public double myComplexMathMethod() {<br />
		return (PI * 100);<br />
	}<br />
}</p>
<p><a href="http://en.wikipedia.org/wiki/Constant_interface" rel="nofollow">http://en.wikipedia.org/wiki/Constant_interface</a> &#8211; has good information related to the topic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Divakar</title>
		<link>http://javapapers.com/core-java/what-is-a-static-import-in-java/comment-page-1/#comment-267</link>
		<dc:creator>Divakar</dc:creator>
		<pubDate>Tue, 17 Nov 2009 21:53:29 +0000</pubDate>
		<guid isPermaLink="false">http://javapapers.com/?p=65#comment-267</guid>
		<description>Interesting , I never knew that you can import a static method in java. Looks cool. But to me , it would be easy to read / understand if we associate the class name. i.e Math.cos rather calling cos()</description>
		<content:encoded><![CDATA[<p>Interesting , I never knew that you can import a static method in java. Looks cool. But to me , it would be easy to read / understand if we associate the class name. i.e Math.cos rather calling cos()</p>
]]></content:encoded>
	</item>
</channel>
</rss>
