java interface
public interface Exampleinterface {
public void menthod1();
public int method2();
}
class ExampleInterfaceImpl implements ExampleInterface {
public void method1()
{
//code here
}
public int method2()
{
//code here
}
}// Interface
interface Animal {
public void animalSound(); // interface method (does not have a body)
public void sleep(); // interface method (does not have a body)
}
// Pig "implements" the Animal interface
class Pig implements Animal {
public void animalSound() {
// The body of animalSound() is provided here
System.out.println("The pig says: wee wee");
}
public void sleep() {
// The body of sleep() is provided here
System.out.println("Zzz");
}
}
class MyMainClass {
public static void main(String[] args) {
Pig myPig = new Pig(); // Create a Pig object
myPig.animalSound();
myPig.sleep();
}
}
Also in Java:
- java stream filter
- java bubble sort short circuit
- iterate hashmap java
- jframe border
- math.pow java
- left shift in java
- java stream remove
- spigot deal damage
- java create clas
- java classes and methods simple logic with comments
- list java oracle
- arraylist set method
- set java
- find frequency of each word in a string in java
- lopp array java
- Could not resolve project :app
- java observable
- add two numbers bitwise
- cordova cannot find symbol import com.google.firebase.iid.FirebaseMessagingService;
- how to check the lines in a file java scanner
- write an infinite loop java
- java arraylist add to top
- java sort method
- android switch on change