急!请各位帮看看 Stack.push(Object obj),not primitive int,try ues the correspend Wrapper class. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你应该将其用类进行包装,如楼上所说,如果你想将整形压入栈中,可用Integer kofwr(搭补流二) 我知道这里存在类型不兼容的问题,但如何解决。能说详细一些吗?我刚刚开始java,谢谢study_body(为什么总是长不大) 用Integer 也不可以,刚刚试过。 import java.util.*;public class Conversion1{ private int N,d,c,result; private String res=new String(); private Stack s=new Stack(); public void Init() //获取要转换的数N,以及要转的进制树d { System.out.println("Please Input N"); N=System.in.read(); System.out.println("please Input d"); d=System.in.read(); } public void Count()//进行转换 { while ((c=System.in.read())=='\n') { while (N!=0) { result=N%d; s.push(result); N=N/d; } } } public void Result()//输出转换结果 { while (!s.isEmpty()) { res=s.pop().toString(); System.out.println(res); } } public static void main(String[] args) { Conversion1 st=new Conversion1(); st.Init(); st.Count(); st.Result(); }}还是不行,请问该怎样封装????? java错误:the hierarchy of type "类名" is inconsistent tomcat安装失败 GuI问题 关于Java的两个小问题 关于数组的调用 大家帮忙谢谢 为什么一个对一个错呢? 在一个普通的bean中怎么调用连接池? 如何创建对象数组 Applet开发问题(请教有实际Applet开发经验的高手) java中策略文件是什么意思? 我用Jbuilder 做的Application1编译后怎么没有Exe文件?我是初学者,请教各位。 我的线程运行运行就没了???
study_body(为什么总是长不大) 用Integer 也不可以,刚刚试过。
public class Conversion1
{
private int N,d,c,result;
private String res=new String();
private Stack s=new Stack();
public void Init() //获取要转换的数N,以及要转的进制树d
{
System.out.println("Please Input N");
N=System.in.read();
System.out.println("please Input d");
d=System.in.read();
} public void Count()//进行转换
{
while ((c=System.in.read())=='\n')
{
while (N!=0)
{
result=N%d;
s.push(result);
N=N/d;
}
}
} public void Result()//输出转换结果
{
while (!s.isEmpty())
{
res=s.pop().toString();
System.out.println(res);
}
}
public static void main(String[] args)
{ Conversion1 st=new Conversion1();
st.Init();
st.Count();
st.Result();
}
}
还是不行,请问该怎样封装?????