Interfaces in Java
package com.company;
interface Bicycle{
int a = 45;
void applyBrake(int decrement);
void speedUp(int inrement);
}
class AvonCycle implements Bicycle{
public void applyBrake(int decrement){
System.out.println("Applying Brake");
}
public void speedUp(int inrement){
System.out.println("Applying SpeedUp");
}
}
public class tuts {
public static void main(String[] args) {
AvonCycle cycle = new AvonCycle();
cycle.applyBrake(1);
// You can create properties in Interfaces but, you cannot change them because they are final.
System.out.println(cycle.a);
}
}
Comments
Post a Comment