{"id":58,"date":"2006-01-30T23:30:29","date_gmt":"2006-01-31T04:30:29","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/?p=58"},"modified":"2006-01-30T23:30:29","modified_gmt":"2006-01-31T04:30:29","slug":"java-five-oh-2-static-import","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2006\/01\/30\/java-five-oh-2-static-import\/","title":{"rendered":"Java Five-Oh #2: Static Import"},"content":{"rendered":"<p>Perhaps one of my favorite Java 1.5 features is the static imports.  The way I have explained static import is that it makes available other class members and method as if they were defined locally.  If that didn&#8217;t make much sense, let me demonstrate it with an example.  The java.lang.Math class provides a ton of static helper methods.  Each time you want to use the abs() method for example you have to do so as such:<\/p>\n<pre>\nint absolute = Math.abs(-7);\n<\/pre>\n<p>But with the new static import you can make available all of the methods in the Math class in your own class so you don&#8217;t have to write out Math every time you want to use the abs() method.  So if you static import the Math class you can do this:<\/p>\n<pre>\nint absolute = abs(7);\n<\/pre>\n<p>To declare a static import for the Math class use the following construct:<\/p>\n<pre>\nimport static java.lang.Math.*;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Perhaps one of my favorite Java 1.5 features is the static imports. The way I have explained static import is that it makes available other class members and method as if they were defined locally. If that didn&#8217;t make much sense, let me demonstrate it with an example. The java.lang.Math class provides a ton of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[15,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-W","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/58"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}