首页 > 解决方案 > 如何使用 Get Metod 从海量中提取价值?

问题描述

我有这个代码

public void insertStart_auto_load_test_step_info(int countUsers ) throws SQLException{      
    String insert_auto_load_test_user_info = "insert into auto_load_test_step_info(id_user_info,start_time,step_id) values(" + getIdValue1()+ getCrokStarTime() +  "2";
    PreparedStatement pstmt = this.con.prepareStatement(insert_auto_load_test_user_info, Statement.RETURN_GENERATED_KEYS);
    pstmt.executeUpdate();

而这堂课

public class Info {
    private int crok = 0; 
    private int testId = 0; 
    private int testCaseId = 1; 
    private long starTime; 
    private long crokStarTime; 
    private long crokFinishTime; 
    int [] idValue1 = new int[100];
    int [] idValue2 = new int[100];
    int id_case_info = 0;


    public int[] getIdValue2() {
        return idValue2;
    }
    public void setIdValue2(int idValue2, int i) {
        this.idValue2[i] = idValue2;
    }
    public int getId_case_info() {
        return id_case_info;
    }
    public void setId_case_info(int id_case_info) {
        this.id_case_info = id_case_info;
    }
    public int[] getIdValue1() {
        return idValue1;
    }
    public void setIdValue1(int idValue1, int i) {
        this.idValue1[i] = idValue1;
}

我需要从此方法添加到我的插入值,getIdValue1()我该怎么做?我认为,必须有某种索引,但我不知道如何使用它。

标签: java

解决方案


在您的 setIdValue2() 方法之后对其进行建模。

// You should check, somewhere, that i is a valid index of idValue2
public int getIdValue2(int i) {
  return idValue2[i];
}

现在,您可以调用您的方法:int temp = getIdValue2(0); // Get item at first index


推荐阅读