标签:
1、Pg168--2
package com.hanqi; import java.util.Scanner; public class Rectangle { Rectangle() { //完成初始化 lang=12; wide=10; } //属性 double lang; double wide; //方法 void area() { System.out.println("矩形的面积=" +lang*wide); } public static void main(String[] args) { Rectangle rec=new Rectangle(); System.out.println("矩形的长度=" +rec.lang); System.out.println("矩形的宽度=" +rec.wide); rec.area(); } }
2.计算机完成加减乘除
package com.hanqi; import java.util.Scanner; public class Rectangle { Rectangle() { //完成初始化 lang=12; wide=10; } //属性 double lang; double wide; //方法 void area() { System.out.println("矩形的面积=" +lang*wide); } public static void main(String[] args) { Rectangle rec=new Rectangle(); System.out.println("矩形的长度=" +rec.lang); System.out.println("矩形的宽度=" +rec.wide); rec.area(); } }
标签:
原文地址:http://www.cnblogs.com/wangchuanqi/p/5243743.html