tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code09:38

Learn Java 2D arrays in 9 minutes! ⬜

Bro Code ↗

From the creator

#java #javatutorial #javacourse public class Main { public static void main(String[] args){ // 2D array = An array where each element is an array // Useful for storing a matrix of data //----------------------- // EXAMPLE 1 //----------------------- String[][] groceries = {{"apple", "orange", "banana"}, {"potato", "onion", "carrot"}, {"chicken", "pork", "beef", "fish"}}; groceries[2][1] = "eggs"; for(String[] foods : groceries){ for(String food : foods){ System.out.print(food + " "); } System.out.println(); } //----------------------- // EXAMPLE 2 //----------------------- char[][] telephone = {{'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'}, {'*', '0', '#'}}; for(char[] row : telephone){ for(char number : row){ System.out.print(number + " "); } System.out.println(); } } }

Published 2024-12-05 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code