aspose file tools*
The moose likes Beginning Java and the fly likes Question about overload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about overload" Watch "Question about overload" New topic
Author

Question about overload

Yu-Jie Jang
Greenhorn

Joined: Dec 28, 2003
Posts: 3
Hollo,everyone:
If must transfer overload , what should noted?
if there type the same , how about casting ?
if casting the same ?
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Originally posted by Yu-Jie Jang:
Hollo,everyone:
If must transfer overload , what should noted?
if there type the same , how about casting ?
if casting the same ?

Hi Yu and welcome to the ranch, i am not trying to be rude here, but can you please clarify what you are saying, cause honestly... i have no idea what you're talking about.


- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Yu-Jie Jang
Greenhorn

Joined: Dec 28, 2003
Posts: 3
sorry i missing one question
when I overload :
B extends A
A a=new A();
A b=new B();
if A have private vaiable x and default y,
B have private y and default x,
methed call ?
variable call ?
Chao Chihwai
Greenhorn

Joined: Sep 24, 2003
Posts: 5
Hello Yu:
After reading what you mentioned, I think your question is not about overload, it may be override.When one class has methods which have same name and different types of arguments, like:
public int method(){};
private double method (int x){};

The question you mentioned can be separate into 2 parts variable and method();
Variale:
Without considering the static or instance variables,when you call the variable, it depends on the type.It means if the code is A a = new B(); when you call a.x or a.y, it will show the class A's variable value.
Method():
1.It is different in static and instance method().First, The static method() can't override instance method() and instance method() can't override static method.
2.If the subclass and it's superclass have same static method();when you call the method();it depends on type like variable(This situation may be called Hide).
3.If the subclass and it's superclass have same instance method();when you call the method();it depends on type like object.It means if the code is A a = new B(); when you call a.x(), it will execute the class B's method().Thos situation may be called override.
Conclude( s = static i = instance)

Please tolerat my poor English, and hope it can help you !
[ December 28, 2003: Message edited by: Chao Chihwai ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about overload