java - Display stars based on array values using showOptionDialog -


what best way display each value in array n times star in case (using showoptiondialog)? considering using loop, i'm not sure i'd fit in code.

code far:

int[] stars = {2,4,6};  string[] options = {"yes","no"} int choice = joptionpane.showoptiondialog(null, "stars1: " + stars[0]...                      + "\n stars2:" + stars[1]...                      + "\n stars3:" + stars[2]...,              "stars", 0, 3, null, options, null); 

expected output:

** **** ****** 

hope makes sense, thanks!

you can try this:

int[] stars = {2,4,6}; string[] starsstr = new string[stars.length]; for(int = 0;i < stars.length;i++){     string temp = "";     for(int j = 0; j < stars[i];j++){        temp+="*";     }     starsstr[i] = temp; } string[] options = {"yes","no"}; int choice = joptionpane.showoptiondialog(null, starsstr,      "stars", 0, 3, null, options, null); 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -