1 package com.aila; 2 3 public class Ailajiang { 4 5 6 public static void main(String[] args) { 7 int[] arr = new int [30]; 8 arr[0] = 1; 9 arr[1] = 1; 10 for(int i = 2;i < arr.length;i++) 11 arr[i] = arr[i - 1] + arr[i - 2]; 12 for(int i : arr) 13 System.out.println(i); 14 } 15 16 17 }
1 package com.aila; 2 3 public class ailasang { 4 public static void main(String[] args) { 5 human hm[] = new human[3]; 6 hm[0] = new human("aila",19); 7 hm[1] = new human("ailala",18); 8 hm[2] = new human("ailalala",20); 9 for(int i = 0;i < hm.length;i++) 10 hm[i].getInfo(); 11 } 12 13 } 14 15 class human{ 16 private String name; 17 private int age; 18 public human(String name,int age) { 19 this.name = name; 20 this.age = age; 21 } 22 public void getInfo() { 23 System.out.println("姓名:" + this.name + " 年龄:" + this.age); 24 25 } 26 }