Random test generation in java

Posted on 2008-11-12
Last Modified: 2012-05-05
I need to create and send a random text to a user whenever a new user id is created ... i don wanna involve any cipher to create this random text... this should be purely random  , can you help me in writting a random text generator code in java.
Question by:FranklinRaj22
    LVL 86

    Expert Comment

    Try the following:
    String randText = Integer.toString((int)(Math.random() * Integer.MAX_VALUE), 36);

    Open in new window

    LVL 7

    Accepted Solution

    Here is a web page which describes a decent function also:
    LVL 15

    Assisted Solution

    This one will make a random string of upper case letters of your choice

    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		 int achar;
    		 char i;
    		 String randomKey = "";
    		 for(int y = 0; y < 10; y++)
    		 achar = 65 + (int)((Math.random() * Integer.MAX_VALUE)%26);
    		 i = (char)achar;
    		 randomKey = randomKey + i;

    Open in new window


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    instanceof  operator in java 26 56
    hash value 2 29
    Fibonacci challenge 11 61
    Exception after setting jdbc session management 2 17
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now