LintCode-454.Rectangle Area
来源:互联网 发布:添加windows凭据 编辑:程序博客网 时间:2024/05/20 16:12
URL:http://www.lintcode.com/en/problem/rectangle-area/
Implement a Rectangle
class which include the following attributes and methods:
- Two public attributes width and height.
- A constructor which expects two parameters width and height of type int.
- A method
getArea
which would calculate the size of the rectangle and return.
Rectangle rec = new Rectangle(3, 4);rec.getArea(); // should get 12
考查 Java面向对象的特征public class Rectangle { public int height; public int width; public Rectangle(int height, int width) { this.height = height; this.width = width; } public int getArea(){ return this.height * this.width; } public static void main(String[] args) { Rectangle rectangle = new Rectangle(3, 4); int area = rectangle.getArea(); System.out.println(area); }}
阅读全文
0 0
- LintCode-454.Rectangle Area
- [LintCode]Rectangle Area(Java)
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- 【紫书】(UVa1347)Tour
- Sringmvc的理解上
- 关于华为手机使用MTK刷机时出现failed to get PMT info的解决办法
- 06_动态规划科室
- 说说Java代理模式
- LintCode-454.Rectangle Area
- 几种基本数据类型选择
- 【龙芯1c库】在裸机编程环境中常用的中断接口简介
- 数据结构——顺序表删除之建表算法
- jzoj 2017.10.05 模拟赛
- InnoDB引擎以及合适选择
- 【linux 服务器运行情况】了解Linux服务器运行情况
- 存储引擎的选择
- 基本日期数据类型