Java job 13 (), java job
/* Use an array to solve the issue of Series 1, 2, 3, 5, 8, and 13. the Fibonacci series: Fibonacci */package cn. GM; public class array {public static void main (String [] args) {// TODO Auto-generated method stubint arr [] = new int [30]; arr [0] = 1; arr [1] = 1; for (int I = 2; I <arr. length; I ++) {arr [I] = arr [I-1] + arr [I-2]; System. out. println (arr [I]) ;}}
/* Select method. Arranged from small to large */package cn. GM; public class yiwei {public static void main (String [] args) {// TODO Auto-generated method stubint [] arr = {10,347,657, 38,382, 75, 76, 56,123 44, 84654};/* select method. Ascending Order */for (int I = 0; I <arr. length-1; I ++) {for (int j = I + 1; j <arr. length; j ++) {if (arr [I]> arr [j]) {int temp = arr [I]; arr [I] = arr [j]; arr [j] = temp ;}}for (int I: arr) System. out. println (I );}}
/* Bubble method. Arranged from small to large */package cn. GM; public class yiwweiM {public static void main (String [] args) {// TODO Auto-generated method stubint [] arr = {10,347,657, 38,382, 75, 76, 56,123 44, 84654};/* bubble method. Ascending Order */for (int I = 0; I <arr. length; I ++) {for (int j = 0; j <arr. length-1-I; j ++) {if (arr [j]> arr [j + 1]) {int temp = arr [j]; arr [j] = arr [j + 1]; arr [j + 1] = temp ;}}for (int I: arr) System. out. println (I );}}
/* Array of human objects-a bunch of people */package cn. GM; public class personarr {public static void main (String [] args) {// TODO Auto-generated method stub // create array person arr [] = new person [3]; arr [0] = new person ("Zhao Yi", 20); arr [1] = new person ("Ouyang Nana", 17 ); arr [2] = new person ("Family Name", 32); for (int x = 0; x <arr. length; x ++) arr [x]. getInfo () ;}} class person {private String name; private int age; public person (String name, int age) {this. name = name; this. age = age;} public void getInfo () {System. out. println ("name:" + this. name + "Age:" + this. age );}}