java笔记整理(3)
来源:互联网 发布:陈都灵知乎 编辑:程序博客网 时间:2024/06/04 01:35
圆的面积:
public class Circle{
private double radius;
Circle(){
radius=1;
}
Circle(double r){
radius=r;
}
Circle(Circle c){
radius=c.radius;
}
public void setRadius(double r){
radius=r;
}
public double getRadius(){
return radius;
}
public double getArea(){
return Math.PI*radius*radius;
}
}
public class Example{
public static void main(String args[]){
Circle c=new Circle();
c.setRadius(2);
System.out.println(c.getArea());
}
}
圆柱的面积:
public class Cylinder{
private double bottom;
private double height;
Cylinder(){
bottom=1;
height=1;
}
Cylinder (double b,double h){
bottom=b;
height=h;
}
Cylinder(Cylinder cy){
bottom=cy.bottom;
height=cy.height;
}
public void setBottom(double b){
bottom=b;
}
public void setHeight(double h){
height=h;
}
public double getBottom(){
return bottom;
}
public double getHeight(){
return height;
}
public double getArea(){
return bottom*height;
}
}
public class Example1{
public static void main(String args[]){
Cylinder c1=new Cylinder();
c1.setBottom(5);
c1.setHeight(2);
System.out.println(c1.getArea());
}
}
- java笔记整理(3)
- Java笔记整理(1)
- Java笔记整理(2)
- Java反射学习笔记(待整理)
- JAVA设计模式笔记整理(一)
- JAVA设计模式笔记整理(二)
- JAVA设计模式笔记整理(三)
- JAVA设计模式笔记整理(四)
- 我的Java笔记整理(1)
- 笔记整理(java基础六-----异常)
- 笔记整理(java基础八-----多线程)
- 笔记整理(java基础十----集合)
- JAVA学习笔记整理一(基础知识)
- JAVA学习笔记整理八(多线程)
- JAVA学习笔记整理九(IO)
- java if语句(笔记整理)
- Java WebService 整理笔记
- java学习整理笔记
- DeepID训练过程中loss居高不下解决方法
- 浅谈前端跨域的几种解决方式
- Oracle锁表、解锁、批量解锁表
- 脚本编程
- 提权系列(一)----Windows Service 服务器提权初识与exp提权,mysql提权
- java笔记整理(3)
- iOS updateViewConstraints
- Markdown——编辑器语法——背景色
- 27. Remove Element
- iOS A/B Test 方案探索
- Elasticsearch5.2.1集群搭建,动态加入节点,并添加监控诊断插件
- Tensorflow实现全链接神经网络
- 关于Android studio Logcat显示不全,不显示自己需要打印的LOG数据
- jquery动画2