Wednesday 23 December 2015

Java Tutorial : Java Class Methods or Static Methods


Click here to watch in Youtube :
https://www.youtube.com/watch?v=q1yPqx3HB4o&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Class Methods or Static Methods
ClassMethodTest.java
public class ClassMethodTest
{

    public static void main(String[] args)
    {
        ClassMethodTest.display("Hello");

        ClassMethodTest classMethodTest = new ClassMethodTest();

        /*
         * You can also refer to static methods with an object reference like
         * below. but this is discouraged because it does not make it clear that
         * they are class methods.
         */
        classMethodTest.display("Peter");
    }

    /*
     * Static methods, which have the static modifier in their declarations,
     * should be invoked with the class name, without the need for creating an
     * instance of the class.
     */
    public static void display(String str)
    {
        System.out.println(str);
    }

}
Output
Hello
Peter
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/ClassMethodDemoApp.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ClassMethodDemoApp

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/14218d6dfc0ba96c475ae9bea5112ff3ce747d04/BasicJava/ClassMethodDemoApp/?at=master

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