• Post Reply Bookmark Topic Watch Topic
  • New Topic

casting + error  RSS feed

 
John Valiant
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can anyone see my error?


ProblemSet5.java:63: error: ';' expected
System.out.println((GoldFish)owner.pets[ 9 ]).getAction("*Rat eats alot*" ));
^
1 error

 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Look at your parens. I've numbered them in pairs. You can see that the S.o.p method is closed at the second '1', so it makes no sense to then put the dot operator on the end.
 
John Valiant
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks fred, cant believe i missed it
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get yourself a decent text editor, eg NotePad++, NotePad2, jEdit, and set up bracket highlighting as an option. It is surprising how many errors are caused by mis-counted () [] and {}.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!