• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

non-static method nextBoolean() cannot be referenced from a static context error

 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
error:

What is wrong and how can I fix it? initdir and upslashdown are of String type FYI.
Thanks,
cc11rocks
 
Henry Wong
author
Marshal
Pie
Posts: 21185
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
john price wrote:error:

What is wrong and how can I fix it? initdir and upslashdown are of String type FYI.
Thanks,
cc11rocks


Basically, the nextBoolean() method is *not* a static method. You need to have an instance of the Random object to call it -- you just can't specify it with the Random class.

Henry
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. All i had to do was add:

Then I changed it to:

Thanks so much!
John Price aka cc11rocks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic