Java编测试程序

来源:百度知道 编辑:UC知道 时间:2024/05/17 08:25:17
public class JiaQi
{
public interface Interface1
{
public abstract void ArrayStack ();
public abstract boolean isEmpty();
public abstract void makeEmpty();
public abstract int top();
public abstract void pop();
public abstract int topAndPop();
public abstract void push(int x);
public static final int DEFAULT_CAPACITY = 10;
}
public static void main(String[] args)
{

//System.out.println("Hello World!");
class text implements Interface1
{
private int[] theArray;
private int topOfStack;
public void ArrayStack()
{
theArray = new int[DEFAULT_CAPACITY];
topOfStack = -1;
}

public boolean isEmpty()
{
return topOfStack == -1;
}

public void makeEmpty()
{
topOfStack = -1;
}

public void push(int x)
{

你这个程序还是错的啊,汗,
Integer I=new Integer(i);这个I是对象,
用JAVA的封装类.

把接口里的int型都换成object型 然后实现类里也一样
测试程序就是接口声明 实现类实例化 然后调用方法

Integer I=new Integer(i);这个I是对象,