Guest User

Untitled

a guest
Aug 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. /**
  2. * Converts a list of treeIds from a string to an integer array
  3. * @param treeIds : list of tree ids seperated by commas
  4. * @return : integer array of tree ids
  5. */
  6. private int[] getTreeIDs(String treeIds) {
  7. treeIds = treeIds.trim(); // remove any white space from the list of ids
  8. final String [] trees = treeIds.split(","); // create a seperate string for each tree id that is seperated by a ','
  9. final int [] tree_ids = new int [trees.length]; // create an integer array to store the tree ids
  10. for(int i = 0; i < trees.length; i++) {
  11. // iterate through the array of tree id strings and convert them to integers and place them inside the tree id integer array
  12. tree_ids[i] = Integer.parseInt(trees[i]);
  13. }
  14. return tree_ids;
  15. }
Add Comment
Please, Sign In to add comment