java - How to return multiple conditions? -


what should return @ end of loop? i'm trying display added results of 3 parties numdemocrat, numrepulican , numindepent calculating , printing number of democrats (party "d"), republicans (party "r"), , independents (party else). i'm looping on memberofcongress arraylist returned parsemembersofcongress , counting how many of each party type there are. in loop need check party current member belongs , increment proper variable. after loop completes print totals.

public void printpartybreakdowninsenate()      {      congressdatafetcher.fetchsenatedata(congressnum);     }       {     arraylist<memberofcongress> parsemembersofcongress; string jsonstring;      }      {      system.out.println("number of members of senate of " + "&congressnum=" + "?chamber=");     }      public string[]       {          int numdemocrats = 0;          int numrepblican = 0;          int numindepent = 0;           arraylist<memberofcongress> members;         (memberofcongress memberparty : members) {               if (memberparty.getparty() == "d" ) {                  numdemocrats++;              }              else if (memberparty.getparty() == "r" ){                        numrepblican++;                  }                  else if (memberparty.getparty() == "null"){                            numindepent++;                  }          }            return ???;  } 

firstly i'm 99% positive cannot return multiple values, unless return either array, array list or map.

but work around 1 of following.

1). return string array of party members.

2). return 2d array mapping name age or similar.

3). return hashmap of data custom class of information mapped name.

4). use getters different pieces of data @ time or @ once.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -