fork download
  1. public class Main {
  2. public static void main(String[] args) {
  3.  
  4. Column[] columns = {
  5. // 列の型, 列の名前
  6. new Column(Table.Type.Integer, "レス番号"),
  7. new Column(Table.Type.String, "名前"),
  8. new Column(Table.Type.String, "メール"),
  9. };
  10.  
  11. Table table = new Table(columns);
  12. // さきほどの列の定義に従って、レス番号、名前、メールの組をテーブルに追加
  13. table.insert(324, "名無しさん", "sage");
  14. table.insert(412, "コテハン", "age");
  15.  
  16. // テーブルの全てのレコードを取得して画面に表示
  17. for (int i = 0; i < table.getAllRecords().length; i++){
  18. Object[] records = table.select(i);
  19. for (int j = 0; j < records.length; j++){
  20. switch (table.getType(j)) {
  21. case String:
  22. System.out.println(table.getAttribute(j) + " : " + (String)records[j]);
  23. break;
  24. case Integer:
  25. System.out.println(table.getAttribute(j) + " : " + (Integer)records[j]);
  26. break;
  27. default:
  28. break;
  29. }
  30. }
  31. System.out.println();
  32. }
  33. }
  34. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty