Join Peggy Fisher for an in-depth discussion in this video Solution: Groceries, part of Up and Running with Java.
- This challenge was designed to provide you with the…opportunity to use ArrayLists and to get an idea…of how to search for a specific item in an ArrayList.…Let's take a look at my solution but remember,…your solution might be very different.…One of the things that you might have noticed…with this solution is we had to do an import…of both the java.util.ArrayList as well as…the java.util.Scanner.…So I started by creating an ArrayList of…type string called groceries.…Then I added five grocery items.…
Bananas, wheat bread, 1% milk,…crackers and oatmeal.…The next thing I wanted to do was to present…the list to the end user…and ask them if they want to enter another item.…I chose to allow them to enter another item…or they could type in the word "quit"…if they wanted to exit.…I read in whatever value they typed.…I needed a boolean variable called found so that…I knew whether or not I found a match.…I need you to scroll down now.…My while loop is set up to compare whatever…value they entered to the word quit.…
If they entered quit, my while loop will not execute.…
- 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.