Upto-Dream 2017-01-03 11:47 采纳率: 50%
浏览 1113
已采纳

java迭代遍历值时,为什么会输出16进制,要怎么转换

import java.util.*;
public class qqqq{

private int getBianhao() {
    return bianhao;
}
private void setBianhao(int bianhao) {
    this.bianhao = bianhao;
}
private String getMingchen() {
    return mingchen;
}
private void setMingchen(String mingchen) {
    this.mingchen = mingchen;
}
private Integer bianhao;
private String mingchen;
public qqqq(Integer bianhao,String mingchen){
    this.bianhao=bianhao;
    this.mingchen=mingchen;
}
public static void main(String[]args){
    HashMap<Integer,qqqq> hash=new HashMap<Integer,qqqq>();
    qqqq one1=new qqqq(1,"苹果1");
    qqqq one2=new qqqq(2,"苹果2");
    qqqq one3=new qqqq(3,"苹果3");
    qqqq one4=new qqqq(4,"苹果4");
    qqqq one5=new qqqq(5,"苹果5");

    hash.put(1,one1);
    hash.put(2,one2);
    hash.put(3,one3);
    hash.put(4,one4);
    hash.put(5,one5);
    Collection<qqqq> collection = hash.values();
    Iterator<qqqq> itt=collection.iterator();
    System.out.println("输出值");//输出的老是16进制码
    while(itt.hasNext()){
    System.out.println(itt.next());
    }
    Set<Integer>keys=hash.keySet();
    System.out.println("输出键");
    Iterator tt=keys.iterator();
    while(tt.hasNext()){
        System.out.print(tt.next()+"\t");
    }
    System.out.println("输出完整的信息");
    for(Integer key:keys){
        System.out.println("编号:"+key+"\t名称:"+hash.get(key));
    }
}

}

  • 写回答

3条回答 默认 最新

  • 夕阳雨晴 2017-01-03 11:58
    关注

    对象直接输出输出的是该对象存储的地址,你如果非要直接输出对象需要重载对象的toString函数。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿