Join Carlos Rivas for an in-depth discussion in this video Parse the data, part of Code Clinic: Java.
- [Instructor] Now that we have our line…from the input file separated into individual tokens,…we can parse those tokens,…create a WeatherEntry object with them,…and load them into our collectedData array.…Let's do that now.…First we're going to create a WeatherEntry object…which we'll call entry.…Next we're going to load the specific values…that we're interested in,…in this case, barometric pressure.…
It's worth noting that the values are stored…in the wordsArray line line 28 as strings,…so we need to do a conversion,…which we're doing now.…Based on the header row in our input file,…we remember that the barometric pressure…is the third value in our array,…which will be array index two.…We use the helper class,…Float in this case,…to do a conversion from string to float.…
Since we also added a humidity value,…which is also present in our input files,…we're going to add it here.…It's also a float…and needs to be converted from string.…It is positioned in array index number four…in our input file.…With our weather entry completed…
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
- 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.