JAVA final keyword, constant definition, final keyword

Source: Internet
Author: User
Tags constant definition

JAVA final keyword, constant definition, final keyword

Final (final) is a modifier
1. final can be used to modify classes, functions, and variables (member variables, local variables)
2. Classes modified by final cannot be inherited by other classes.
3. Methods (functions) modified by final cannot be overwritten.
4. The variable (attribute) modified by final cannot be assigned another value. final must assign a value when modifying the variable. The variable after final modification is called a constant.

Define constant: final type capital constant name = constant value
Constant naming rules: uppercase letters are required. If the name is composed of multiple words, the words are separated _.

Public class Test {public static void main (String [] args) {final String TITLE = "TITLE"; // defines the constant System of the String type. out. println (TITLE );}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.