• Post Reply Bookmark Topic Watch Topic
  • New Topic

RockPaperScissors  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




(and this one)

in my first program an error like this is appearing on my application:

Rockz.java:34: int cannot be dereferenced
humanRps = humanRps.toUpperCase();
^
1 error

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

can you guys help me how should i fix it? thanks!
 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is exactly in a place your compiler pointed.
Variable humanRps is of type int. You can not execute a method toUpperCase() on int. Well, you can not execute ANY method on int because it is primitive type and does not have any fields nor methods.

Also, I noticed an error in your random number generation.

Please UseCodeTags <- click
 
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote: . . . Please UseCodeTags <- click
Since OP is new, I have added code tags this time, and doesn't it look better now.

Welcome to the Ranch Ogie Santos

There is always something wrong with a method as long as yours. A main method should be short. Very short. Any method that long is a mistake until proven otherwise.
The code tags also highlight the inconsistent formatting: some {} indented and some not, and ifs and if‑elses crammed together without {}. Have a look at our formatting suggestions. Consistent formatting and indentation make it much easier to avoid errors.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!