Learn INTERFACES in 6 minutes! 📋

preview_player
Показать описание
#java #javatutorial #javacourse

public class Main {
public static void main(String[] args) {

// Interface = A blueprint for a class that specifies a set of abstract methods
// that implementing classes MUST define.
// Supports multiple inheritance-like behavior.

Rabbit rabbit = new Rabbit();
Hawk hawk = new Hawk();
Fish fish = new Fish();

}
}
public interface Prey {

void flee();
}
public interface Predator {

void hunt();
}
public class Rabbit implements Prey{

@Override
public void flee(){
}
}
public class Hawk implements Predator{

@Override
public void hunt(){
}
}
public class Fish implements Prey, Predator{

@Override
public void flee(){
}

@Override
public void hunt(){
}
}
Рекомендации по теме
Комментарии
Автор

public class Main {
public static void main(String[] args) {

// Interface = A blueprint for a class that specifies a set of abstract methods
// that implementing classes MUST define.
// Supports multiple inheritance-like behavior.

Rabbit rabbit = new Rabbit();
Hawk hawk = new Hawk();
Fish fish = new Fish();

rabbit.flee();
hawk.hunt();
fish.flee();
fish.hunt();

}
}
public interface Prey {

void flee();
}
public interface Predator {

void hunt();
}
public class Rabbit implements Prey{

@Override
public void flee(){
System.out.println("*The rabbit is running away*");
}
}
public class Hawk implements Predator{

@Override
public void hunt(){
System.out.println("*The hawk is hunting*");
}
}
public class Fish implements Prey, Predator{

@Override
public void flee(){
System.out.println("*The fish is swimming away*");
}

@Override
public void hunt(){
System.out.println("*The fish is hunting*");
}
}

BroCodez
Автор

Explained and I understood the assignment within one video watch, thank you, take my like +1

PlusMinu
Автор

so many videos, all at the same time!

Ctrl-Z-Renders
Автор

I am from Bangladesh, I watch every video of you, I like your videos very much, you make videos very beautifully. Thank you very much

md.o.btuhin
Автор

So the purpose of this is to ensure that new classes are set up correctly?

weemanling
Автор

Can you make some videos on how to use Insomnia. And videos on NoSQL 😊

LOLFUNNYTIKTOKS
Автор

Hello bro. Why don't you post on chocobro channel😢

rianrafi
Автор

Set of abstract methods that implementing class must define

Samtoosoon
Автор

i was just writing interfaces code from geeksforgeeks but understand nothing then got this notification

officialdreamplayz