请问这是什么错误? 我编译已经通过了。。。
import java.util.Stack;
import java.io.*;
public class addlongnum{
public Stack ran(){ 输入一些数存到堆栈中,并且返回这个堆栈
Stack a= new Stack();
try{
char num=(char)System.in.read();
while (num!='\n'){
a.push(new Character(num)) ;}
} catch (Exception e){}
return a;
}
public void statues(Stack a){ 把堆栈中的元素都打印出来
while (a.isEmpty()==false){
System.out.print(a.pop()+" ");
}
}
public Stack addlongnum(Stack a,Stack b){//长整数加法 就是把a,b两个堆栈中的数逐一取出相加然后存在另一个堆栈中
Object tem=new Object();
Object tema=new Object();
Object temb=new Object();
int d=0;
Stack stack=new Stack();
for(;a.isEmpty()==false&&b.isEmpty()==false;){
tema=a.pop();temb=b.pop();
int c = Integer.parseInt(tema.toString())+Integer.parseInt(temb.toString())+d;
if(c<=9)
d=0;
else
{
d=1;
c=c-10;
}
stack.push(new Integer(c));
}
for(;a.isEmpty()==false;){
if(d==1){
tema=a.pop();
int e=Integer.parseInt(tema.toString())+d;
stack.push(new Integer(e));
d=0;
}
else
{
stack.push(a.pop());
}
}
for(;b.isEmpty()==false;){
if(d==1){
temb=b.pop();
int e=Integer.parseInt(temb.toString())+d;
stack.push(new Integer(e));
d=0;
}
else
{
stack.push(b.pop());
}
}
return stack;
}
public static void main(String arg[]) {
Stack a=new Stack();
Stack b=new Stack();
addlongnum xiaohe =new addlongnum();
System.out.println("enter a");
a=xiaohe.ran(); 显示到这就弹出错误!!!
System.out.println("enter b");
b=xiaohe.ran();
xiaohe.statues(xiaohe.addlongnum(a,b));
}
}
[此贴子已经被作者于2007-1-11 1:53:50编辑过]