Tampilkan postingan dengan label class. Tampilkan semua postingan
Tampilkan postingan dengan label class. Tampilkan semua postingan

What is a Constructor in Object Oriented Programming?

Posted by Unknown Rabu, 29 Januari 2014 0 komentar
Constructor is specialized method that is contained in a class. Constructor will be triggered automatically when an object is created. Purpose of the Constructors is to initialize an object of a class.

Constructor’s name is identical to the Class name. Constructors can take parameters but constructors have no return type. This is because; constructors return an object by itself.

Static Constructor
When a constructor of a class is marked with static modifier, then the constructor is called static constructor. Unlike other constructors, Static constructor cannot be triggered while creating instances of that class.

Static constructors will be automatically triggered when the class is loaded for the first time. Static constructors are used to initialize values for the static variables of that class.

Baca Selengkapnya ....

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(); }

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