How to generate string with given range.

Say there is drop down list to select range e.g. 1-9 and based on that range you need to input value in text field having length equal to range.

public class testlength {
public static String test(int idgit) {
String s = null;
Random m = new Random();

      // take a temp string and initialize it randomly or hardcoded it
String temp = "5" //Integer.toString(m.nextInt(8));
for(int i=1; i<idgit+k;i++) {
int j= m.nextInt(8);
    s = Integer.toString(j);
    temp = temp+s;
}
return temp;
}

Comments

Popular posts from this blog

Comparing sum of string's digit by splitting string in 2 halfs

Parsing xml node tags using documentbuilderfactory