如何在android中将对象转换为字符串数组

时间:2015-01-21 12:50:16

标签: java android

您好在此代码的朋友值返回一个对象。但我想返回返回值数组的字符串数组。 同时调试它给这样的 [at.vcity.androidim.types.FriendInfo@b2e758d8, at.vcity.androidim.types.FriendInfo@b2e6d160]的java

FriendInfo [] friend = FriendController.getFriendsInfo();

friendinfo.java

public class FriendInfo{




        public static final String FRIEND_LIST = "friendList";
        public static final String USERNAME = "username";
        public static final String IP = "IP";
        public static final String PORT = "port";
        public static final String USER_KEY = "userKey";
        public static final String MESSAGE = "message";  
        public static final String STATUS = "status";
        final boolean[] checked = null;

        public STATUS status;

        public String userName;
        public String ip;
        public String port;
        public String userKey;
        public String expire;


};

1 个答案:

答案 0 :(得分:1)

您必须覆盖toString()

例如

@Override
public String toString() {
     return userName;
}