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

What are the differences between final and static keywords

2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you the "what are the differences between final and static keywords", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what are the differences between final and static keywords" this article.

Can modify classes, methods, and member variables.

Static can modify the code block of a class, but final cannot.

Static cannot modify local variables within a method, but final can.

Static modifiers represent static or global. The modified properties and methods belong to the class and can be named by the class. Static property / method name access

The static-decorated code block represents a static code block, which is executed only once when the Java virtual machine (JVM) loads the class.

Static-modified properties, that is, class variables, are created and initialized when the class is loaded, and will only be created once

Variables modified by static can be reassigned

This and super keywords cannot be used in static methods

The static method must be implemented, not an abstract abstract

The static method can only be overridden by the static method to denote a constant and cannot be changed once created.

Member variables of final tags must be assigned at the same time as they are declared, or in the constructor of the class, and cannot be reassigned.

Final methods cannot be overridden by subclasses

The final class cannot be inherited, there are no subclasses, and the methods in the final class are final by default

Final cannot be used to modify constructors

Methods of type private default to those of type final

These are all the contents of this article entitled "what are the differences between final and static keywords?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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