package com.shine;
public class Entry {
int n;
public Entry() {
// this.n = 6;
n = 8;
System.out.println("Entry constructor: " + toString());
}
public static void main(String[] args) {
System.out.println("...");
Entry mEntry = new Entry();
System.out.println(mEntry);
System.out.println("mEntry: " + mEntry.toString());
System.out.println("n = " + mEntry.n);
mEntry.methodA(9);
System.out.println("An = " + mEntry.n);
mEntry.methodB(7);
System.out.println("Bn = " + mEntry.n);
}
public void methodA(int m) {
n = m;
System.out.println("methodA: " + toString());
}
public void methodB(int n) {
this.n = n; //当成员方法的参数与成员变量相同时,使用this区别成员变量
System.out.println("methodB: " + toString());
}
}
public class Entry {
int n;
public Entry() {
// this.n = 6;
n = 8;
System.out.println("Entry constructor: " + toString());
}
public static void main(String[] args) {
System.out.println("...");
Entry mEntry = new Entry();
System.out.println(mEntry);
System.out.println("mEntry: " + mEntry.toString());
System.out.println("n = " + mEntry.n);
mEntry.methodA(9);
System.out.println("An = " + mEntry.n);
mEntry.methodB(7);
System.out.println("Bn = " + mEntry.n);
}
public void methodA(int m) {
n = m;
System.out.println("methodA: " + toString());
}
public void methodB(int n) {
this.n = n; //当成员方法的参数与成员变量相同时,使用this区别成员变量
System.out.println("methodB: " + toString());
}
}