debug中调试程序时,输出的数字是十六进制??不好看,怎么改成十进制输出。。方便查看调试情况。。 debug中调试程序时,输出的数字是十六进制??不好看,怎么改成十进制输出。。方便查看调试情况。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int i = Integer.parseInt("AA",16); System.out.println(i); 我的java程序是这样的。class ProducerConsumer{public static void main(String[] args){ SyncStack ss=new SyncStack(); Producer p=new Producer(ss); Consumer c=new Consumer(ss); new Thread(p).start(); new Thread(c).start(); }}class WoTou{ int id; WoTou(int id){this.id=id;} public String tostring(){ return "WoTou:" + id; } } class SyncStack{ int index=0; WoTou[] arrWT=new WoTou[6]; public synchronized void push(WoTou wt){ if(index==arrWT.length){ try{ this.wait(); }catch(InterruptedException e){ e.printStackTrace(); } } this.notify(); arrWT[index]=wt; index ++; } public synchronized WoTou pop(){ if(index==0){ try{ Thread.sleep(1000); }catch(InterruptedException e){ e.printStackTrace(); } } this.notify(); index--; return arrWT[index]; } } class Producer implements Runnable{ SyncStack ss=null; Producer(SyncStack ss){ this.ss=ss; } public void run(){ for(int i=0;i<20;i++){ WoTou wt=new WoTou(i); ss.push(wt); System.out.println("生产了:" + wt); try{ Thread.sleep(1000); }catch(InterruptedException e){ e.printStackTrace(); } } } } class Consumer implements Runnable{ SyncStack ss=null; Consumer(SyncStack ss){ this.ss=ss; } public void run(){ for(int i=0;i<20;i++){ WoTou wt=ss.pop(); System.out.println("消费了:" + wt); try{ Thread.sleep(1000); }catch(InterruptedException e){ e.printStackTrace(); } } } }在debug中调试输出的是:生产了:WoTou@1a758cb消费了:WoTou@1a758cb生产了:WoTou@1b67f74消费了:WoTou@1b67f74....不应该输出这个16进制的啊,这个不是十进制的,怎么回事? toString未写正确!嗯,谢谢!! JAVA输入问题 SCJP一道题目求解。 DataInputStream,DataOutputStream 问题? Java杂谈(九)--Struts2 自己做的FCKeditor2.6.2 for java例子 在线等:一个TreeMap类,想实现先put的东西排序在前,该怎么实现Comparator接口啊 可以直接考scjd么!不考scjp 请大家向我介绍学习java的书,我是初学者! 介绍几个java的好网站,到sun公司下载太慢了 请教最简单的显示控制问题 发帖求个冒泡排序的算法,在线等 一样的代码,得到的结果不一样,为什么哦?
int i = Integer.parseInt("AA",16);
System.out.println(i);
class ProducerConsumer{
public static void main(String[] args){
SyncStack ss=new SyncStack();
Producer p=new Producer(ss);
Consumer c=new Consumer(ss);
new Thread(p).start();
new Thread(c).start();
}
}
class WoTou{
int id;
WoTou(int id){
this.id=id;
}
public String tostring(){
return "WoTou:" + id;
}
}
class SyncStack{
int index=0;
WoTou[] arrWT=new WoTou[6];
public synchronized void push(WoTou wt){
if(index==arrWT.length){
try{
this.wait();
}catch(InterruptedException e){
e.printStackTrace();
}
}
this.notify();
arrWT[index]=wt;
index ++;
}
public synchronized WoTou pop(){
if(index==0){
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
this.notify();
index--;
return arrWT[index];
}
}
class Producer implements Runnable{
SyncStack ss=null;
Producer(SyncStack ss){
this.ss=ss;
}
public void run(){
for(int i=0;i<20;i++){
WoTou wt=new WoTou(i);
ss.push(wt);
System.out.println("生产了:" + wt);
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}
}
class Consumer implements Runnable{
SyncStack ss=null;
Consumer(SyncStack ss){
this.ss=ss;
}
public void run(){
for(int i=0;i<20;i++){
WoTou wt=ss.pop();
System.out.println("消费了:" + wt);
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}
}
在debug中调试
输出的是:生产了:WoTou@1a758cb
消费了:WoTou@1a758cb
生产了:WoTou@1b67f74
消费了:WoTou@1b67f74
.
.
.
.不应该输出这个16进制的啊,这个不是十进制的,怎么回事?