1 Reply Latest reply on Sep 25, 2006 4:27 AM by 807598

    Random String Generation

      Hi I have a problem where I want to generate a Random String from a list of Strings. EG. from { east, west, north, south} now every time generate one out of this 4 strings. is it possible?
        • 1. Re: Random String Generation
          there are many ways to do it ,one way is

          store the strings in an array and retrive them randomly try this
          private String randomString(){          
                    String depts[] ={"East","West","North","South"}; 
                    Random randomNumber = new Random();
                    int deptNo = randomNumber.nextInt(4);          
                    return depts[deptNo];