How to write interfaces in java or Android?

Posted by Unknown Senin, 18 Februari 2013 0 komentar
what is an Interface?
An interface is a collection of abstract methods. A class 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.

MainActivity.java
public class MainActivity extends Activity implements Interface {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public void testFunctionOne() {
System.out.println("Print from testFunctionOne in the Interface");
}
@Override
public void testFunctionTwo() {
System.out.println("Print from testFunctionTwo in the Interface");
}}
in Interface.java
public interface Interface  {    
void testFunctionOne();
void testFunctionTwo(); }
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: How to write interfaces in java or Android?
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidpopuler.blogspot.com/2013/02/how-to-write-interfaces-in-java-or.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.