java - How can I add an object to an arraylist of objects -


the purpose add teams arraylist. each team object string name, string division, int wins, , int losses.

import java.util.arraylist; import java.util.arrays; public class default  {      arraylist<team> teams = new arraylist<team>();      team mavericks = new team("mavericks","southwest",50,32);      team rockets = new team("rockets","southwest",56,26);      team grizzlies = new team("memphis","southwest",55,27);      teams.add(team mavericks);      teams.add(team rockets);      teams.add(team grizzlies); } class team {     string name, division;     int win,loss;     public team(string n,string d, int w, int l)     {         this.name = n;         this.division = d;         this.win = w;         this.loss = l;     }  } 

it

 teams.add(team mavericks);  teams.add(team rockets);  teams.add(team grizzlies); 

should be

 teams.add(mavericks);//here mavericks object  teams.add(rockets);  teams.add(grizzlies); 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -