Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

java 一段代码没有明白,求解答,谢谢

  String str = "room_id=6911880153266785031&hold_living_room=1&is_login=0&enter_from_uid_by_shared=0&scenario=0&enter_source=live_merge-live_cover&live_reason=rec&request_id=2020123012065401019805303328010566&enter_type=draw";
        String s[]= str.split("&");
        System.out.println(String.valueOf(s));

结果为

[Ljava.lang.String;@17f052a3

我明明是把字符串切割组合成一个数组,但是结果大相径庭,这是为啥?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

s可以理解为是个数组的指针,直接输出指针的值那就是个地址
你这样输出就能看见了:

        String str = "room_id=6910155031&hold_living_room=1&is_login=0&enter_from_uid_by_shared=0&scenario=0&enter_source=live_merge-live_cover&live_reason=rec&request_id=202066&enter_type=draw";
        String s[]= str.split("&");
        for (String st : s) {
            System.out.println(st);
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...