Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Noob problem..

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I've recently started to program in java...and I have a problem with some code I've written and I can't see where the problem is.

I get the following error:

int cannot be dereferenced

Here is my code:




BlueJ tells me the error is on this line:

Member m = new Member(lastName, firstName, sex, date, score1, score2, score3, score4. score5, score6, score7, score8, score9, score10);

Any help would be much appreciated
 
author
Posts: 23919
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

BlueJ tells me the error is on this line:

Member m = new Member(lastName, firstName, sex, date, score1, score2, score3, score4. score5, score6, score7, score8, score9, score10);

Any help would be much appreciated



Can you give us the exact error message? There is nothing being dereferenced at that line.

Henry
 
Jack Nutkins
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeh bluej is a bit messed up in that respect. If its not on that line then it will be on the line above. As the lines above are all similar then I have a feeling it's somewhere on the lines scores 1 - 10.
The exact error message is as said above:

int cannot be dereferenced

Cheers
 
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Somewhere you have an int variable, let's call it x for now, which you are trying to dereference: where y is either a field or a method. The compiler will tell you the exact line.
 
Henry Wong
author
Posts: 23919
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The exact error message is as said above:

int cannot be dereferenced



That doesn't say anything... Of course, an int can't be dereferenced. You need the full error message from the compiler. And if BlueJ is not showing you the error, and compile it by hand.

Henry
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This might be the cause of the problem (in the line where you create the Member).

 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

D. Ogranos wrote:

This might be the cause of the problem (in the line where you create the Member).



Good eye! Indeed, that period ought to be a comma, and that is definitely the source of the error message.
 
Everybody's invited. Even this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic