package com.heima.test; public class Test7 { public static void main(String[] args) { Week2 mon = Week2.MON; //这里的类名.对象的引用 (这种用法是什么意思?) System.out.println(mon); } } class Week2 { public static final Week2 MON = new Week2("星期一"); public static final Week2 TUE = new Week2("星期二"); public static final Week2 WED = new Week2("星期三"); private String name; private Week2(String name){ //私有构造,不让其他类创建本类对象 this.name = name; } public String getName() { //提供getName方法 return name; } @Override public String toString() { //重写tostring方法 return name; } }
问题在黄色标注那里,知道的解答写
|