Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

What is the keyword that is equivalent to "final" in Java

조회 수: 2 (최근 30일)
Rajesh Gangireddy
Rajesh Gangireddy 2018년 10월 5일
마감: Sabin 2023년 3월 7일
I want a way to implement the concept of "final" in java . I don't want few methods of my class to be overridden by a subclass. Is there a way or a keyword that is equivalent to this concept.
Here's the code of java which i am trying to implement in matlab.
public abstract class CaffeineBeverage {
final void prepareRecipe ( ) {
boilWater ( );
brew ( );
pourInCup ( );
addCondiments ( );
}
abstract void brew ( );
abstract void addCondiments ( );
void boilWater ( ) {
System.out.println (Boiling Water);
}
void pourInCup ( ) {
System.out.println(Pouring into cup);
}
}
Here, prepareRecipe() is declared final as i dont want any subclasses to be able to override this method and change the recipe.

답변 (0개)

이 질문은 마감되었습니다.

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by