Explored using 2D arrays

This commit is contained in:
Cameron Seamons 2026-01-11 19:42:07 -07:00
parent 5bf00ee959
commit c340aaf216
2 changed files with 25 additions and 0 deletions

Binary file not shown.

View file

@ -0,0 +1,25 @@
public class Numpad {
public static void main(String[] args){
// This project is to show how to use 2D Arrays
// a.k.a. Nested arrays (an array of arrays)
// 2D arrays are useful for storing a matrix of data.
// Remember - Characters are single quotes 'C'
char[][] numpad = {{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}};
// We need nested loops to print columns and rows
for(char[] row : numpad){
for(char number : row){
System.out.print(number + " ");
}
// Between every row add an empty line
System.out.println();
}
}
}