Java – the keyword “class” is in the declaration

I was faced with a rather simple question in the interview

Why do we use the class keyword to declare classes?

Solution

Short answer: because this is the way of C Java takes up most of the syntax in C - in my opinion, it's a wise decision because it really helps drawing programmers in the new era

Now, if your question is why you need a keyword, that's why the compiler can't infer which classes are declared - maybe, but the advantage of using a keyword is

>Easier to compile > easier to read than implied declarations. > As mentioned above – similar to C syntax

Editor: other things - some things can't be deduced by the compiler in Java syntax at all - for example, the only difference between an empty class and an empty interface (which is legal in Java) is the class / interface keyword

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>