Thomas Kellerer wrote:
Vishal, 25.03.2008 16:50:
i want the code for this program :
54444
54333
54322
54321
public class UselessCode
{
public static void main(String[] args)
{
System.out.println("54444");
System.out.println("54333");
System.out.println("54322");
System.out.println("54321");
}
}
I'm pretty sure that can't be right. There isn't enough
computation involved. *This* code however, has
enough computations to be right:
public class Foo {
public static void main(String args[]) {
int value;
while ((value = aNumber()) != 54444);
System.out.println(""+value);
while ((value = aNumber()) != 54333);
System.out.println(""+value);
while ((value = aNumber()) != 54322);
System.out.println(""+value);
while ((value = aNumber()) != 54321);
System.out.println(""+value);
}
public static int aNumber() {
if (null == rand) rand = new java.util.Random();
int result = 0;
for (int i = 0; i < 5; ++i) {
result = (10*result)+rand.nextInt(5)+1;
}
return result;
}
private static java.util.Random rand = null;
}
--
Steve Wampler -- swamp...@noao.edu
The gods that smiled on your birth are now laughing out loud.
It's not nearly enterprisey enough. You should implement an EJB to
generate the random numbers. When one of the required numbers is
cache, which should be periodically updated from the database). The