(Java)polimorfisme / Polymorphism

Polymorphism is the ability of a variable of a type / class to be used as a reference / reference objects of different types, and can automatically dial a specific method for each type.

Polymorphism pl = new Polymorphism();
pl = new Polymorphism;

Example :

public class Turunan {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Customer cs = new Customer();
        cs = new Customer();
        cs.setId(3);
        System.out.println("hasil :"+cs.getID());
        
        
        MemberCustomer ms = new MemberCustomer();
        ms.setMember("Staff");
        System.out.println("Member :"+ms.getMember());
        
    
        
    }
}
<pre> 

Reference :
Ebook Java Desktop Ifnu Bima

Advertisements

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s