我正在研究谷歌圖表API和 谷歌可視化燭臺圖預計數據是一個數組的數組,它可以工作。如何從結果集構建數組數組
例如下面的格式
[
[ "2011-08-01", 136.65, 136.96, 134.15, 136.49 ],
[ "2011-08-02", 135.26, 135.95, 131.50, 131.85 ],
[ "2011-08-05", 132.90, 135.27, 128.30, 135.25 ]
]
這是我的SQL由我正在檢索從數據庫中的數據
String selectsql = "select current_day , open_val , high_val , low_val , close_val from historical_data where symbol_name = ?";
while(Rset.next())
{
String current_day = SgxRset.getString("current_day");
String open_val = SgxRset.getString("open_val");
String high_val = SgxRset.getString("high_val");
String low_val = SgxRset.getString("low_val");
String close_val = SgxRset.getString("close_val");
}
你能告訴我如何構建如何構建陣列數組
示例程序
import java.util.ArrayList;
import java.util.List;
import org.json.JSONException;
public class TestJSON {
public static void main(String[] args) throws JSONException {
Employee emp1 = new Employee();
emp1.setName("Ravi");
emp1.setName("20");
Employee emp2 = new Employee();
emp2.setName("Kiran");
emp2.setName("20");
List<Employee> histList = new ArrayList<Employee>();
Object[] arrayResultData = histList.toArray();
}
}
public class Employee {
String name ;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
String age ;
}
怎麼樣使用多維數組? –
我不認爲這是一個數組的數組。它有一個字符串,其他的是浮點值。 –
如果你不知道有多少行,你不需要一個數組的數組,因爲你不能調整數組的大小 - 你需要一個數組的列表或類似的東西。 –