java - JOptionPane parsing arrays -


i new java , arrays. trying parse string input int , array. import javax.swing.joptionpane;

        public class osl          {                 string[] colortype = {"blue", "green", "white"};                 final int colours = 3;    // tshirt colours choices                 int[] color = new int[colours];                 int order;              public osl()             {                   (int index = 0; index < colortype.length; index++)                 {                     string orderitems = joptionpane.showinputdialog("please enter number of t-shirts " + colortype[index]);                     int items = integer.parseint(orderitems);                 }                  (int index = 0; index < color.length; index++)                 {                     joptionpane.showmessagedialog(null, colortype[index] + ": " + color[index]);                 }                    }                 int orderitems;          public int getorderitmes()             {                 return orderitems;             }              public static void main(string[] args)             {                new osl();             }            } 

i can input integer not display them.

simply put, never apply quanity each color color array in way. example, like...

for (int index = 0; index < colortype.length; index++) {     string orderitems = joptionpane.showinputdialog("please enter number of t-shirts " + colortype[index]);     int items = integer.parseint(orderitems);     color[index] = items; } 

which applies quantity user inputted each element in color array


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -