我們把main成員函數的參數args稱為命令行參數
class doRect
public static void main(String args[])
int w=Integer
int h=Integer
Rectangle myrect=new Rectangle(w
myrect
class Rectangle
int width
public Rectangle(int w
width=w;
height=h;
area=getArea(w
protected int getArea(int w
int a;
a=w*h;
return a;
public void drawRect()
int i
for(i=width;i>
System
System
for(i=height
System
for(j=width
System
System
for(i=width;i>
System
System
用Javac編譯該程序後
javac doRect
java doRect
注意這裡的
From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/25456.html