Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the object-oriented final keyword of Java

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the Java object-oriented final keyword how to use, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

/ * * knowledge points: final keyword 1. What is final: final is the final meaning 2. The variable modified by the final keyword cannot be modified by a constant. The method modified by the final keyword cannot be overridden by a subclass. The class modified by the final keyword cannot be inherited by * / public class FinalKeyword {public static void main (String [] args) {final double PI = 3.14 System.out.println (PI); / / instantiate father Father f = new Father (); f.work (); / / instantiate son Son s = new Son (); s.study () }} / / Father class Father {public final void work () {System.out.println ("doing farm work"); / / son class Son extends Father {public void study () {System.out.println ("study hard and make progress every day") }} / daughter final class Daughter extends Father {} / grandson class GranSon extends Son {} Thank you for reading this article carefully. I hope the article "how to use the final keyword of Java object-oriented" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report