SHARE
TWEET

Untitled

a guest Jun 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Animal{
  2. }
  3. public class Dog extends Animal{
  4. }
  5.      
  6. public class Run{
  7.     public void get_dog (Dog a){
  8.         System.out.println("got a dog");
  9.     }
  10.     public static void main(String[] args) {
  11.         Animal a_animal = new Dog(); //Create a Animal variable with Dog class
  12.         Run test = new Run();
  13.         System.out.println(a_animal.getClass().getSimpleName());
  14.         test.get_dog(a_animal); //This will not run
  15.     }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top