Rookie notes: Java variable naming and camel-named method

Source: Internet
Author: User

As the hotel will give each room a personalized name, the variables in the program also need to use a reasonable name for the management---variable name!

It is important to note that the name of the hotel room can be a number, such as "802", can also be interesting names, such as "Peony", "President of the United States", "Water curtain hole", etc., but in the name of the variable must conform to certain rules, as follows:

The following variables are named in accordance with the specification:

But take a look at the following code, you know ha:

The habit of good siege master:

1, the variable name consists of multiple words, the first letter lowercase, followed by the first letter of the word capitalization, commonly known as camel-named method (also known as hump name), such as MyAge

2, when the variable name, as short as possible and can clearly express the role of variables, do see the name of understanding. Such as: Define variable name stuname save "student name" information

The length of the Ps:java variable name is not limited, but the Java language is case-sensitive, so price and price are two completely different variables Oh!

The following popularity of the peak camel naming method:

Camel-style nomenclature is when a variable name or function name is a unique identifier consisting of one or more words, the first word starts with a lowercase letter, the first letter of the second word is capitalized, or the first letter of each word is in uppercase letters, for example: MyFirstName, Mylastname, Such variable names look like camel peaks, so they get their name. The term camel-named (camel-case) is a camel that comes from the widely used case-and-write format in Perl, and the cover picture of Programming Perl (O ' Reilly), a bestseller of Larry Wall. The naming rules of camel-like nomenclature can be regarded as a convention, and there is no absolute and mandatory, in order to increase recognition and readability. Small Hump method is usually identified by small hump method. The Hump method means that in addition to the first word, the first letter of the word is capitalized. For example, int mystudentcount; variable Mystudentcount The first word is all lowercase and the first letter of the following word is capitalized. The big hump method compared to the small hump method, the big hump method (that is, Pascal named) the first word of the initial letter is capitalized. Commonly used for class names, function names, properties, namespaces. For example, public class Databaseuser;

Rookie notes: Java variable naming and camel-named method

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.