/** * Author: Josiah Yoder et al. * User: yoder * Class: SE1011-011 * Lesson: Week 9, Day 3 */ public class Example011_9_3 { public static void main(String[] ignored) { // For the trace example int x; Complex011_9_3 c1; x = 5; c1 = new Complex011_9_3(4,9); c1 = new Complex011_9_3(2,10); // Instance -- What's being pointed to. A copy of the class in memory // with its own values for instance variables. // Class -- Definition of an object, including methods & variables & constants. // Object -- Instance of the class. // Instance variables -- have a potentially different value // for each instance // Class variables -- have same values in every instance of the class // In fact, no instance is needed to access them. // // Class variables are designated with the "static" keyword. // // Class variables are often overused. /* Instance methods have direct access to instance variables and class variables. They have a "this" reference. Class methods have direct access only to class variables. */ // See RandomStatic011_9_3 for example of top-down implementation with // class methods // See RandomFun011_9_3 for improved example that uses good ol' instance // methods and takes advantage of OO principles. } }