This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Int cannot be dereferenced Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Int cannot be dereferenced" Watch "Int cannot be dereferenced" New topic

Int cannot be dereferenced

Mark Kaichou

Joined: Feb 13, 2012
Posts: 2
I've been spending hours and hours trying to figure what have I done wrong to no avail, I've spent a load of time online trying to figure it out but I still can't!!!
Error's at line 154 :/

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11881

topTiming is declared as an int - a primitive type. Therefore, it doesn't have a length.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

What would you expect that to mean? Primitives (byte, char, short, int, long, float, double, boolean) are not objects and do not have member variables or methods. They're just simple values. So you cannot do somePrimitive.something.
Mark Kaichou

Joined: Feb 13, 2012
Posts: 2
Ahhhhh, I see, silly me, thanks for the prompt reply guys!
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

toptiming isn't an array ... you can't have length for primitive datatypes ...
I agree. Here's the link:
subject: Int cannot be dereferenced
It's not a secret anymore!