Win a copy of Head First Android this week in the Android forum!
  • 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
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Is This Considered a Different Parameter List?

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is merely changing x to final in the go() method enough to consider this a different parameter list, and therefore an overloaded version of the method? Or is it the same parameter list and therefore an overridden version of the method?

If I limit the access of the method in Hello2 (by making it default), the compiler complains that I can't do that when overriding, so the compiler must consider final int x the same parameter list. I suppose this answers the question, but I just want to verify this with others.

Thank you,
-Russ

 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Russ Russell wrote:Is merely changing x to final in the go() method enough to consider this a different parameter list, and therefore an overloaded version of the method?



Nope. Parameter lists are distinguished only by the types of their args and the order in which those args appear.
 
Russ Russell
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you , Jeff.

Swapping the order of the parameters in the list is considerend a different signature?
 
Sheriff
Posts: 22504
122
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
Well, you have already answered your own question, so there's not much more to say. Perhaps only that only the types and order of the parameter list is considered. Names, annotations and modifiers (like final) are not.

Edit: in answer to your second question, only if the types of the variables are different is it considered a different signature. Swapping two int parameters will not change a thing.
 
Russ Russell
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both. Crystal clear.

-Russ
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic