View RSS Feed

Recent Blogs Posts

  1. Using this with a Field

    by , 04-26-2012 at 05:40 PM
    The this keyword usage has a reason that field gets shadowed by constructor parameter or method.

    For example the Point class is as following written:
    Java Code:
    public class Point {
        public int x = 0;
        public int y = 0;
            
        //constructor
        public Point(int a, int b) {
            x = a;
            y = b;
        }
    }
    However, other way to write it is;
    Java Code:
    public class Point {
    ...