• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Illegal modifier for parameter

 
Leroy J Brown
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So,
I'm working with a Java book and I'm playing around trying to understand some basic java concepts and I write some do nothing code to teach myself about overriding methods and I'm getting an error I don't understand at all.

File 1

File 2


Now, I was planning on implementing the compoundIterate method on line marked twelve in the Account class and then overriding it in SavingsAccount method on line marked 8, so I can play around and learn but I'm already getting errors and not sure what they're about. I use Eclipse IDE. All errors mentioned hereafter are in class Savings account.

@Line 8: "Illegal modifier for parameter compoundIterate; only final is permitted"
  • If I replace "public" with "final" the error goes away. Why does it want me to make this method final?

  • @Line 8: under the comma between years and monthlyInvest parameters "syntax error on token "," ; expected"

    @Line 8: under the closing parenthesis for the method signature "syntax error on token ")" ; expected"
  • replacing either of these "tokens" with a semicolon makes the error go away which doesn't make ANY sense to me at all

  • @Line 11: "Void methods cannot return a value"

  • the method signature clearly has a double return type. Why in the world does Eclipse think this method has a void return type?


  • I'm guessing I'm doing something basic wrong and Eclipse is giving me a bunch of errors that would go away if i changed it. Debugging features can tell you when something is wrong but often give misleading errors because they don't know what you're trying to do - but... I don't know what the deal is. A hint please?
    [ June 21, 2008: Message edited by: Tristan Rouse ]
     
    Taariq San
    Ranch Hand
    Posts: 192
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    compoundIterate is seen as a parameter, in fact it's a method.
    You're missing the right curly bracket for your constructor SavingsAccount.

    Your file compiles after that.
    [ June 21, 2008: Message edited by: Taariq San ]
     
    Leroy J Brown
    Ranch Hand
    Posts: 71
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The super constructor was auto-generated by eclipse at my behest and I must have accidentally deleted the right curly brace. Thanks!
     
    Taariq San
    Ranch Hand
    Posts: 192
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Tristan Rouse:
    The super constructor was auto-generated by eclipse at my behest and I must have accidentally deleted the right curly brace. Thanks!


    You're welcome.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic