Tampilkan postingan dengan label methods. Tampilkan semua postingan
Tampilkan postingan dengan label methods. Tampilkan semua postingan

What is Static Member?

Posted by Unknown Rabu, 29 Januari 2014 0 komentar
Static member is a member that belongs to the class and not to the objects of the class. Static members are specified using the keyword static. The three valid static members of a class are static constructor, static variable and static method.

Static Variables:
When a variable or attribute of a class is declared as static then it is called as Static Variable. Only one copy of static variable will be stored in the memory. All the objects of the class will be accessing the same copy of it.

Static Methods:
Static methods are the methods which are marked as static. Static method can access only static members of a class. Static methods cannot access non-static or instance members of a class.

Static Constructors:
Static constructors are special type of constructors that are called when the class is loaded for the first time. Static constructors are used to initialize static variables of a 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.