Java vs C # naming rules

Source: Internet
Author: User

Package (namespace)

Java package: it is a lowercase noun that can be separated by vertices. For example, java. AWT. event;

C # namespace: the first letter is capitalized. Generally, multiple words are combined into a class name. the first letter of each word must also be capitalized, for example, system. Data. sqlclient;

Class

Java and C # are the same: The first letter is capitalized. Generally, a class name is composed of multiple words, and the first letter of each word must be capitalized, for example, class helloworldapp;

Interface Name

Java: The naming rule is the same as the class name, for example, Interface collection.

C #: The naming rule is the same as the class name, but I must be added before, for example, icollection and iclone.

Method Name

Java: It is often composed of multiple words. The first word is usually a verb, the first letter is lowercase, and the first letter of each word in the middle must be capitalized, for example: balanceaccount,
Isbuttonpressed;

C #: Same as the class, uppercase letters are required. For example, tostring ().

Variable name:

Java and C # are the same: All lowercase letters, generally nouns, such as length;

Constant name

Java and C # are the same: constants of the basic data type are named in uppercase. If they are composed of multiple words, they can be separated by underscores (_). For example: int year, int
Week_of_month; if it is a constant of the object type, it is a mix of uppercase and lowercase, separated by uppercase letters.

 

Other Java:

Switch (expression ){
Case value1: statement1;
Break;
Case value2: statement2;
Break;
............
Case valuen: statemendn;
Break;
[Default: defaultstatement;]
}

◇ The return value type of expression must be int, byte, Char, and short.
◇ The value valuen In the case clause must be a constant, and the values in all case clauses should be different.
◇ The default clause is optional.
◇ The break statement is used to makeProgramExit the switch statement, that is, terminate the execution of the switch statement (in some special cases, multiple different case values need to execute the same group of operations, then you do not need to use break ).

StringOperations on strings are not performed on the Source Operation String object, but on copying a New Source Operation String object. The operation results do not affect the source string.

On the contrary,StringbufferThe connection operation on the string is performed on the source string itself. After the operation, the value of the source string changes to the connected string.

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.