📄 location3d.java
字号:
package examples.errors;
import examples.inheritance.Location2D;
/** A class intended to create an error
*/
public class Location3D extends Location2D {
protected int z;
public Location3D( int initX, int initY,
int initZ ) {
x = initX;
y = initY;
z = initZ;
}
public static void show2D( Location2D p2 ) {
// The line below results in a compiler error
// because the data members are not accessible
System.out.println( "(" + p2.x + ", "
+ p2.y + ")" );
}
public static void show3D( Location3D p3 ) {
System.out.println( "(" + p3.x + ", " + p3.y
+ ", " + p3.z + ")" );
}
static public void main( String[] args ) {
Location3D a = new Location3D( 1, 2, 3 );
Location3D.show3D( a );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -