cylinder.java
来自「Java面向对象编程(随书配套源代码) 阐述了面向对象编程的思想」· Java 代码 · 共 28 行
JAVA
28 行
package chapter8;
class Cylinder
{
double radius;
double depth;
Cylinder (double r, double d)
{
this.radius = r;
this.depth = d;
}
public String toString()
{
return " Dimensions are " + this.radius + " by " + this.depth + ".";
}
}
class ToStringDemo
{
public static void main(String args[])
{
Cylinder c = new Cylinder (10, 14);
String s = "Cylinder c: " + c; // concatenate Cylinder object
System.out.println(c); // convert Cylinder to string
System.out.println(s);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?