Java Interface (Part 2)

This tutorial will show you, how to use a java interface that we create in my previous post. When we want to use a java interface, we must overwrite abstract method that contain in the interface. Source code below will overwrite abstract method in java interface (CreateInterface) called print(). Before we can use a java interface we must put implements keyword followed by interface name. You also must import interface into your program. In the example below, i don't import the interface because, it's location is same with this java file.

*******************************************************
COMPLETE SOURCE CODE FOR : UseJavaInterface.java
*******************************************************


public class UseJavaInterface implements CreateInterface
{
public void print()
{
System.out.println("HI");
}
}


*******************************************************
JUST COMPILE AND EXECUTE IT
*******************************************************
Related Posts Plugin for WordPress, Blogger...

I Also Can Create T-Shirt Logo For You