开发者

I'm getting wrong String value

void displayId(PrintWriter stdOut, StringResources resources, IPatchBundle group, String[] ids){


        for(int i=0;i<ids.length;i++)
                System.out.println("Mids from cmdMds"+ids);
}

The above code produces [Ljava.lang.String;@152cf21. I tr开发者_如何学JAVAied putting .toString() too, still getting the same. Please help me to get the actual value.


Change

System.out.println("Mids from cmdMds"+ids); 

To

System.out.println("Mids from cmdMds"+ids[i]); 

You're trying to print the whole array each time, not the individual elements.


Try:

System.out.println("Mids from cmdMds"+ids[i]);

You want to print the array elements ids[i], not the array itself ids.toString().

[Ljava.lang.String;@152cf21 is decoded as:

  • [ - array
  • L - of object
  • java.lang.String - with class java.lang.String
  • ; - end of type signature
  • @152cf21 - hashCode() as hex


Try:

System.out.println("Mids from cmdMds"+ids[i]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜