1

Here's my current code snippet:

    Iterable<HashMap<String, EntityProperty>> results =
            cloudTable.execute(query, propertyResolver);

    if (results == null) {
        System.out.println("No files processed");
        exit_code = "exit_code=1";
    } else {
        for (HashMap<String, EntityProperty> entity : results) {
            // don't know how to start the loop here 
        }
    }

I have a query for retrieving a list of certain files in Microsoft Azure. Now I just need to show the number of files processed result.

I know the concept of what I should be doing, create a counter within the for loop, and then after the Iterations in that loop, whatever the value of that counter variable, it should also give me the count of files right? I just don't know how to start :( I've been reading so much about Iterable in Java but still can't get a grasp on how it would work.

Any inputs would be greatly appreciated

ajc
  • 1,685
  • 14
  • 34

1 Answers1

0

Like this?

Iterable<HashMap<String, EntityProperty>> results =
        cloudTable.execute(query, propertyResolver);

int counter;
if (results == null) {
    System.out.println("No files processed");
    exit_code = "exit_code=1";
} else {
    counter = 0;
    for (HashMap<String, EntityProperty> entity : results) {
        // don't know how to start the loop here 
        counter++;
    }
    //int size = results.size();
}
Matt
  • 3,052
  • 1
  • 17
  • 30
  • What does the int counter = 0 does exactly? Sorry! I'm really new with java and im learning while making this –  Nov 20 '17 at 19:07
  • it means the counter is starting at 0 then for every interation it will add 1 giving you a total count of all your files – Matt Nov 20 '17 at 19:08
  • Thank you! I tried your code but it's giving me the ff error: The method size() is undefined for the type Iterable> –  Nov 20 '17 at 19:15