• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RockPaperScissors

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What a show! What atmosphere! What fun! What a tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic