Java 非法的表达式开始
publicclassJiaQi{publicstaticvoidmain(String[]args){publicinterfaceInterface{publicab...
public class JiaQi
{
public static void main(String[] args)
{
public interface Interface
{
public abstract void ArrayStack ();
public abstract boolean isEmpty();
public abstract void makeEmpty();
public abstract void top();
public abstract void pop();
public abstract void topAndPop();
public abstract void push();
public static final int DEFAULT_CAPACITY = 10;
}
//System.out.println("Hello World!");
class text implements Interface
{
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)
{
if(topOfStack + 1 == theArray.length)
System.out.println("over flow");
else
theArray[++topOfStack] = x;
}
public int top()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack];
}
public viod pop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
topOfStack--;
}
public int topAndPop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack--];
}
}
}
}
编译后
JiaQi.java:5: 非法的表达式开始
public interface Interface
^
JiaQi.java:5: 需要 ';'
public interface Interface
^
2 错误
------------------------------------
程序怎么回事呀?
------------------------------------
小弟有点不明白,我在网上查了下,怎么非法表达式开始错误分好多,具体怎么回事,高手能给总结下吗? 展开
{
public static void main(String[] args)
{
public interface Interface
{
public abstract void ArrayStack ();
public abstract boolean isEmpty();
public abstract void makeEmpty();
public abstract void top();
public abstract void pop();
public abstract void topAndPop();
public abstract void push();
public static final int DEFAULT_CAPACITY = 10;
}
//System.out.println("Hello World!");
class text implements Interface
{
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)
{
if(topOfStack + 1 == theArray.length)
System.out.println("over flow");
else
theArray[++topOfStack] = x;
}
public int top()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack];
}
public viod pop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
topOfStack--;
}
public int topAndPop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack--];
}
}
}
}
编译后
JiaQi.java:5: 非法的表达式开始
public interface Interface
^
JiaQi.java:5: 需要 ';'
public interface Interface
^
2 错误
------------------------------------
程序怎么回事呀?
------------------------------------
小弟有点不明白,我在网上查了下,怎么非法表达式开始错误分好多,具体怎么回事,高手能给总结下吗? 展开
展开全部
public interface Interface
{
public abstract void ArrayStack ();
public abstract boolean isEmpty();
public abstract void makeEmpty();
public abstract void top();
public abstract void pop();
public abstract void topAndPop();
public abstract void push();
public static final int DEFAULT_CAPACITY = 10;
}
首先interface是JAVA的关键字你怎么能用它来当接口名呢,并且定义一个接口要独立出来,怎么能出现在类里面呢,
theArray = new int[DEFAULT_CAPACITY]; 数组那来一个默认长度啊.
public viod pop() 这里必须有类型啊不能是VOID
{
public abstract void ArrayStack ();
public abstract boolean isEmpty();
public abstract void makeEmpty();
public abstract void top();
public abstract void pop();
public abstract void topAndPop();
public abstract void push();
public static final int DEFAULT_CAPACITY = 10;
}
首先interface是JAVA的关键字你怎么能用它来当接口名呢,并且定义一个接口要独立出来,怎么能出现在类里面呢,
theArray = new int[DEFAULT_CAPACITY]; 数组那来一个默认长度啊.
public viod pop() 这里必须有类型啊不能是VOID
展开全部
public class JiaQi
{
public interface Interface
{
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();
public static final int DEFAULT_CAPACITY = 10;
}
//System.out.println("Hello World!");
class text implements Interface
{
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)
{
if(topOfStack + 1 == theArray.length)
System.out.println("over flow");
else
theArray[++topOfStack] = x;
}
public int top()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack];
return 0;
}
public void pop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
topOfStack--;
}
public void push()
{
}
public int topAndPop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack--];
return 0;
}
}
public static void main(String[] args)
{ }
}
{
public interface Interface
{
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();
public static final int DEFAULT_CAPACITY = 10;
}
//System.out.println("Hello World!");
class text implements Interface
{
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)
{
if(topOfStack + 1 == theArray.length)
System.out.println("over flow");
else
theArray[++topOfStack] = x;
}
public int top()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack];
return 0;
}
public void pop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
topOfStack--;
}
public void push()
{
}
public int topAndPop()
{
if(isEmpty())
System.out.println("the ArrayStack is empty");
else
return theArray[topOfStack--];
return 0;
}
}
public static void main(String[] args)
{ }
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询