2D Array
Iteration with a 2D array
import java.util.*;
public class Array {
String[][] monkeys = {
{
"ʕง ͠° ͟ل͜ ͡°)ʔ ", //[0][0] eyes
" \\_⏄_/ ", //[0][1] chin
" --0-- ", //[0][2] body
" ⎛ ⎞ " //[0][3] legs
},
//Monkey 1
{
" ʕ༼ ◕_◕ ༽ʔ", //[1][0]
" \\_⎏_/ ",
" ++1++ ",
" ⌋ ⌊ "
},
//Monkey 2
{
" ʕ(▀ ⍡ ▀)ʔ", //[2][0]
" \\_⎐_/ ",
" <-2-> ",
" 〈 〉 "
},
//Monkey 3
{
"ʕ ͡° ͜ʖ ° ͡ʔ", //[3][0]
" \\_⍾_/ ",
" ==3== ",
" _/ \\_ "
},
};
public void printMonkeys () {
for (int count = 4; count >= 1; count--) {
System.out.println("Here comes " + count + " monkeys\n");
for (int i = 0; i<monkeys[0].length; i++) {
for (int j = 0; j<count; j++) {
System.out.print(monkeys[j][i] + " ");
}
System.out.println();
}
System.out.println();
System.out.println("Now there are " + (count-1) + " monkeys\n");
}
}
}
Array myRhyme = new Array();
myRhyme.printMonkeys();