Java学习笔记:this使用总结

来源:互联网 发布:php python 比较 编辑:程序博客网 时间:2024/05/24 03:02

1

public class Point {    public int x = 0;    public int y = 0;            //constructor    public Point(int x, int y) {        this.x = x;        this.y = y;    }}

2.

public class Rectangle {    private int x, y;    private int width, height;            public Rectangle() {        this(0, 0, 1, 1);    }    public Rectangle(int width, int height) {        this(0, 0, width, height);    }    public Rectangle(int x, int y, int width, int height) {        this.x = x;        this.y = y;        this.width = width;        this.height = height;    }    ...}

0 0
原创粉丝点击