JAVA试题谁会做啊 求助

[复制链接]
查看11 | 回复0 | 2007-1-4 22:42:55 | 显示全部楼层 |阅读模式
1:package MyPackage; public class MyRectangle { int width; int height; public MyRectangle() { width = 10; height = 20; }public int area(int width,int height) { int area = width * height; return area; } public static void main(String[] args){ MyRectangle mr=new MyRectangle(); System.out.println("矩形面积为:"+mr.area(46, 60)); } }2. public class Test { public int mol(int i){ return i*i; } public int mol(int i,int j){ return i*j; } public void mol(String str){ System.out.println("Hello,"+str+"!"); } public static void main(String[] args){ Test t=new Test(); System.out.println("128的平方等于"+t.mol(128)); System.out.println("12*8="+t.mol(12,8)); t.mol("teacher"); } }
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行