举个例子:public abstract Class Shape
{
public void print();
}public class Circle extends Shape
{
public void print()
{
...
}
}
public class Square extends Shape
{
public void print()
{
...
}
}public class test
{
public void static main(String args[])
{
Shape[] shapes = {new Circle(),new Circle(),new Square(),new Square()};
for (int i = 0; i < shapes.length;i++)
shapes[i].print();
}
}
{
public void print();
}public class Circle extends Shape
{
public void print()
{
...
}
}
public class Square extends Shape
{
public void print()
{
...
}
}public class test
{
public void static main(String args[])
{
Shape[] shapes = {new Circle(),new Circle(),new Square(),new Square()};
for (int i = 0; i < shapes.length;i++)
shapes[i].print();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货