The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Upcasting in a static function?

Posted by Villanueva on April 30, 2001 at 12:17 PM

Hi,

I have a question: Can you upcast in a static function?
The example:

class Brain {
void countNeurons() {
System.out.println("In Brain") ;
}
}
public class HumanBrain extends Brain {
void countNeurons() {
System.out.println("In HumanBrain") ;
}
public static void main (String args[]) {
Brain mix = new HumanBrain() ;
mix.countNeurons() ; // Return: In HumanBrain
}
}

The Question: Can I access with the Object mix the function in Brain?
Something like: mix.super.countNeurons().




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us