Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes static Random Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "static Random" Watch "static Random" New topic
Author

static Random

Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
hi all
to generate random password...i use
static Random rand = new Random();
but on compilation, it gives "illegal start of expression error"..
what cud be the pro..??

tia
MB


Malhar Barai
SOA & Java Book
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4165
    
  21

Try adding a public private or protected befor the static
Steve


Steve
Gopi Balaji
Ranch Hand

Joined: Jan 23, 2003
Posts: 84
Originally posted by Malhar Barai:
hi all
to generate random password...i use
static Random rand = new Random();
but on compilation, it gives "illegal start of expression error"..
what cud be the pro..??

tia
MB

Static variables cannot be defined within methods. They should be enclosed within classes only.
Is this the problem?
-GB.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static Random
 
Similar Threads
WA #1.....word association
Creating a RANDOM_NUM_GENERATOR instance of Random class even though the Random class is static.
random( )
simple random number generator
diff. bet. Math.random() and java.util.random