Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn Java 2D arrays in 9 minutes! ⬜
Play lesson

Java tutorial for beginners ☕ - Learn Java 2D arrays in 9 minutes! ⬜

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#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(); } } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere