小编qae*_*osh的帖子

Java数组记录

我需要得到一个具有3种类型值的变量类型,我知道这样做的唯一方法是"记录",但我知道Java中没有类似"记录"的类型ArrayList,但我不明白...

我的结果应该是:(不知道它在Java中看起来如何,所以我以不同的风格展示)

TData = Record
     Username : String;
     UserID : Int ;
     RowID : Int;
   end;
users : array[1..10] of TData;

for(int i = 1; i < rowCount; i++){
   TData.Username[i] = rs.GetString("Name");
   TData.UserID[i] = rs.GetInt("UserID");
   TData.RowID[i] = row;
}
Run Code Online (Sandbox Code Playgroud)

关于如何制作这样的东西的任何建议?是ArrayList我真正需要的?

感谢您的帮助,最后我结合并得到了这个结果,完美地运作:

class MyData {
        private String userName;
        private int userID;
        private int RowID;


        public MyData(String userName, int userID, int RowID) {
            this.userName = userName;
            this.userID = userID;
            this.RowID = RowID;
        }

        public String getUserName() {
            return …
Run Code Online (Sandbox Code Playgroud)

java arrays records arraylist data-structures

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

arraylist ×1

arrays ×1

data-structures ×1

java ×1

records ×1