Course navigation & on this page
StaticMethod
Original StaticMethod implementation from the supplied Java collection.
Overview
This file is preserved as a supporting course example. Its declarations, methods and comments below are the authoritative description of its behavior.
This reference entry presents original author documentation and source. It is supplementary material, not an additional numbered lecture.
Original course code
Source: code/StaticMethod.java. Original logic, comments, variable names and attribution are retained.
Download StaticMethod.javaStaticMethod.javaJAVA
// Example to illustrate Accessing the Static method(s) of the class. import java.io.*; class Geek{ public static String geekName = ""; public static void geek(String name){ geekName = name; } } class StaticMethod { public static void main (String[] args) { // Accessing the static method geek() and // field by class name itself. Geek.geek("vaibhav"); System.out.println(Geek.geekName); // Accessing the static method geek() by using Object's reference. Geek obj = new Geek(); // we are creating an object of Geek Class obj.geek("mohit"); System.out.println(obj.geekName); } }