Android Java中的LinkedList打印

时间:2014-11-12 12:02:49

标签: java android

我编写以下代码以在textview上打印距离

首先,

LinkedList<String> rawdistance = new LinkedList<String>();
LinkedList<Double> distance = new LinkedList<Double>();

然后,我初始化了两个链接列表,它们都是正确的,然后当我运行以下代码将字符串转换为double时,程序无法在我的设备上工作,即使它没有错误

for (int p=0; p<rawdistance.size(); p++) 
       {
           String tmp = rawdistance.get(p);
           if(tmp.equals(" within ten meter")) {distance.add(p,(double)7);}
           else if(tmp.equals(" within five meter")) {distance.add(p,(double) 3);}
           else if(tmp.equals(" within two meter")) {distance.add(p,(double) 1.5);}
           else if(tmp.equals(" within one meter")) {distance.add(p,(double) 0.5);}
           else 
           {distance.add(p,(double) 11);}

       }

.....


       for (int i=0; i<distance.size();i++)
       {

           textView33.append(distance.get(i) + " encounter");
       }

然后,我在J2SE上编写了smiler代码

公共阶层Friendrr {

public static void Main(String args[]){

    LinkedList<String> rawdistance = new LinkedList<String>();
    LinkedList<Double> distance = new LinkedList<Double>();

    rawdistance.add(0, " within ten meter");
    rawdistance.add(1, " within one meter");
    rawdistance.add(2, " within ten meter");
    rawdistance.add(3, " within two meter");



       for (int p=0; p<rawdistance.size(); p++) 
       {
           String tmp = rawdistance.get(p);
           if(tmp.equals(" within ten meter")) {distance.add(p,(double)7.0);}
           else if(tmp.equals(" within five meter")) {distance.add(p,(double)3.1);}
           else if(tmp.equals(" within two meter")) {distance.add(p,(double)1.5);}
           else if(tmp.equals(" within one meter")) {distance.add(p,(double)0.5);}
           else 
           {distance.add(p,(double)11);}

       }
       for(int i=0; i<rawdistance.size();i++){
       System.out.println(rawdistance.get(i));}
         System.out.println(distance);
    }

} 

输出为[[I @ 5e8fce95]

输出很奇怪..

1 个答案:

答案 0 :(得分:0)

在您编写的JSE代码中

System.out.println(distance);

'distance'是一个对象,'[[I @ 5e8fce95]'是没有任何toString方法的对象的公共字符串表示。