This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static Random

 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding a public private or protected befor the static
Steve
 
Gopi Balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic