An interface is a collection of abstract methods. Aclass implements an interface, thereby inheriting the abstract methods of the interface.

An interface is not a class. Writing an interface is similar to writing a class, but they are two different concepts. A class describes the attributes and behaviors of an object. An interface contains behaviors that a class implements.

Unless the class that implements the interface is abstract, all the methods of the interface need to be defined in the class.

Example :
1. Create Class IntAyah

public  interface IntAyah{
	public void info(String n);

2. Create Class IntAnak

public class IntAnak implements IntAyah{
String nama;
public void info (String n){
	System.out.println("Nama Anak:" + nama);


3. Create class TestInterface

class TestInterface{
public static void main(String []args){
	IntAnak ia = new IntAnak();


Nama Anak : dede

Reference :
– Ebook : Java Desktop Ifnu Bima
– Socket Java Programming STTA


Published by


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s