Join Peggy Fisher for an in-depth discussion in this video Working with two-dimenional arrays, part of Learning Java.
- There are times in programming…where you can't use just a single dimensional array.…For example, how would you create an array…that holds both a list of original prices…and a list of discounts in the same array?…We could use two parallel arrays…but a better way might be to create…a two dimensional array.…If you've ever worked with an Excel spreadsheet…a 2D array is very similar.…In Excel, the columns are labeled A, B, C, D, etc.…and the rows are numbered 1, 2, 3, etc.…
In Java we use the Index position…to reference each cell.…So, instead of A1 for the very first cell in Excel…we use  to indicate the row 0, column 0,…for the first element in our two dimensional array.…Let's start with a syntax for a 2D array in Java.…In this program, I'm gonna create a two dimension array…of prices where the original price is in the first column…and the discounted price is in the second column.…
So, I'm gonna use a double.…When we create a one dimensional array…we have one set of .…But since this array has two dimensions, I need two sets.…
- Downloading and exploring NetBeans
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Creating classes
- Sorting and searching arrays
- Manipulating files
- Handling errors
- Building GUIs
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Flow of Control
4. Classes and Objects
5. Beyond the Basics
6. File Manipulation
7. Graphical User Interface Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.