Created
February 9, 2012 11:26
-
-
Save dbellettini/1779408 to your computer and use it in GitHub Desktop.
weird foreach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set<Author> authorsSet = new HashSet<Author>(); | |
try { | |
for(int i=0; ; i++) { | |
// checking if author already exists in the DB | |
Author author = authorDAO.findAuthorByName(authors[i]); | |
if (author == null) { | |
author = new Author(); | |
author.setName(authors[i]); | |
} | |
authorsSet.add(author); | |
} | |
} catch(ArrayIndexOutOfBoundsException e) { | |
// ignore; this just means that i has reached the end of the array | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment