Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Off With the Head! 22/100 Days of Code

  • March 26, 2019March 26, 2019
  • by Richard Clarke

Another feature down. Now the program can remove an address from the list.

 

Start

As I mentioned previously, when the zip code is in the first address in the list, the program uses the indexOf method to find the first comma in the list. All characters that come before this comma are what make up the first address.

The program then creates a substring of this address before updating the list. The new list is created using a substring from two characters after the end of the address to the end of the original list. This ensures the new list does not begin with a whitespace or a comma. (see below) 

End

When the address containing the zip code is at the end of the list, the program uses the lastIndexOf method to find the last comma in the list. This comma should come right before the last address. The program then obtains the address by taking a substring from after the comma to the end of the list.

The list is updated with a substring from the start of the original list to the character two indexes before the start of the address. This is to ensure the new list ends before the comma, keeping with the proper csv format.

Middle

Now, the program handles middle addresses a little differently. When the address containing the zip code is in the middle of the list, the program finds it and creates a substring from the beginning to the zip code.

After that, the program creates two new substrings from the original list. The first substring is from the beginning of the list to two characters before the address. The second substring is from the comma after the address to the end of the list.

The updated list combines both “halves” of the original list, leaving out the address containing the zip code.

The newly added feature allows the program to update the value of the list with a new String. Next, it needs to obtain the street information from the address. 

Related

We Got the Address! 21/100 Days of Code
How to Loop, 23/100 Days of Code
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode coding Java Programming

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress