String [] aa = {"hello","world"};
String temp = aa.toString();
System.out.println(aa);
System.out.println(temp);
System.out.println(Arrays.deepToString(aa));如果把temp(aa的hashcode)作为参数传给另外的函数,有没有办法透过temp,也即aa的hashcode 逆出aa来??

解决方案 »

  1.   

    当我把temp写到文件中或者数据库里面时候,就不是hashcode了,是真实的数据( [hello,world]),虚拟机做了深拷贝。说明是有可能的。我可以不需要整个数组形式,能得到[hello,world]这种字符串就ok。
      

  2.   

    看看这个 你能通过hashcode找出是哪个map吗
    public static void main(String[] args) {
    HashMap map1 = new HashMap();
    map1.put("a", "aaa");
    HashMap map2 = new HashMap();
    map2.put("a", "aaa");
    System.out.println(map1.hashCode() + "  " + map2.hashCode());
    }
      

  3.   

    那你通过这种形式的hashcode 不就可以了,找麻烦 [hello,world]
      

  4.   

    我感觉是不可行的   temp只是stack里的一个变量而已,你认为它能保存已前的形式?
      

  5.   


    有很多类重写了hashCode方法比如 HashMap就重写了hashCode方法    //Map里的方法
        public int hashCode() {
            int h = 0;
            Iterator<Entry<K,V>> i = entrySet().iterator();
            while (i.hasNext())
                h += i.next().hashCode();
            return h;
        }        //Map.Entry里的方法
            public int hashCode() {
                return (key   == null ? 0 :   key.hashCode()) ^
                       (value == null ? 0 : value.hashCode());
            }
      

  6.   

    你能重写数组的 toString 方法么?好像不行吧数组的 toString 输出的是数组维数、数组类型,以及十六进制的 hashCode,根本不可能得到数据中的数据。
      

  7.   

    晕,你现在的数组是String数组
    如果你是别的对象,看你怎么整