java
1public class Mondai1 { 2 3 public static void main(String[] args) { 4 // 3.氏名の配列を作る。要素数は5,自分の名前を一つ入れる。 5 String[] names = new String[5]; 6 names[0] = "田中次郎"; 7 names[1] = "谷中次郎"; 8 names[2] = "竹中次郎"; 9 names[3] = "田口次郎"; 10 names[4] = "田中一郎"; 11 12 // 4.誕生日のリストを作る。要素数は5、一つ自分の誕生日(19900511) 13 List<String> list = new ArrayList<String>(); 14 list.add("19900511"); 15 list.add("19800411"); 16 list.add("19761105"); 17 list.add("19920615"); 18 list.add("19850918"); 19 20 for (int i = 0; i > names.length; i++) { 21 Date d = new Date(); 22 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); 23 int now = Integer.parseInt(sdf.format(d)); 24 int bir = Integer.parseInt(list.get(i)); 25 int ages = (now - bir) / 10000; 26 names[i] = names[i] + "(" + ages + ")"; 27 28 29 } 30 for (int i = 0; i > names.length; i++) { 31 System.out.println(names[i]); 32 33 } 34 35 }
###意図
エラーがないのにコンソールに表示されません
別のjavaファイルだと表示されなくなります
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。