Tuesday, 8 September 2015

Java Tutorial : Java Static Import

Click the below Image to Enlarge
Java Tutorial : Java Static Import 
Java Tutorial : Java Static Import 

WithOutStaticImportExample.java
import java.lang.*;

/**
 * 
 * Example of With out Static import.
 *
 */
public class WithOutStaticImportExample
{

    public static void main(String[] args)
    {

        int minValue = Math.min(2, 10); // with out static import

        System.out.println("minValue : " + minValue);

        int maxValue = Math.max(12, 20); // with out static import
        System.out.println("maxValue : " + maxValue);

        System.out.println("PI : " + Math.PI); // with out static import

    }

}
StaticImportExample.java
import static java.lang.Math.*;

/**
 * 
 * Example of Static import.
 *
 */
public class StaticImportExample
{

    public static void main(String[] args)
    {

        int minValue = min(2, 10);
        System.out.println("minValue : " + minValue);

        int maxValue = max(12, 30);
        System.out.println("maxValue : " + maxValue);

        System.out.println("PI : " + PI);

    }

}
Output
minValue : 2
maxValue : 20
PI : 3.141592653589793

To Download StaticImportDemoApp Project Click the below link
https://sites.google.com/site/javaee4321/java/StaticImportDemoApp.zip?attredirects=0&d=1

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge