One of the Java notes __java

Source: Internet
Author: User
Tags uppercase letter

Copyright NOTICE: This article is the main original article, without the owner's permission not to reprint

source program (source code): A program written in a high-level language.

The Java program must contain a method named Main, which is executed from the main method; Every statement in Java ends with a semicolon (;), also known as a statement terminator.

Each Java program should have at least one class. Each class has a name. By convention, class names begin with an uppercase letter.

Java source programs are case-sensitive.

Java identifiers: In the Java language: variables, constants, methods, names of classes, collectively known as Java identifiers.

The rules that identifiers must follow:

1. Identifiers can consist of numbers, letters, underscores, and dollar signs.

2. The beginning of the identifier must begin with a letter, underscore, or dollar sign.

3. Identifiers cannot be reserved words and keywords.

4. The identifier can be any length.

Two meanings of the plus sign (+): One is for addition, the other is for strings (string connectors), and when two operands are strings, string connectors concatenate two strings, if one of the two operands is a string and the other is not a string, Operands that are not strings are automatically converted to a string and then connected to another string.

The difference between System.out.println and System.out.print:

System.out.println is automatically wrapped after the output is printed and the output is not wrapped automatically after the result is System.out.print.

According to habit, variable names are expressed in lowercase letters, such as: computer; If the variable name is made up of multiple English words, the first letter of the first English word of the variable name uses the lowercase letter, and the first English letter beginning with the second English word (including the second English word) is capitalized, For example: Computergame; In general, it is best to name variables, such as: you want to give a variable name for the Apple, you can use the English word Apple to give the name of the variable, when other people see this variable, you know that this variable represents an apple, if you arbitrarily give the variable named a, The other people look at your code when you see this variable do not know what it means to contact context, so it is troublesome, so the name of the variable is best known.

Constants are named in uppercase letters, for example, money.

Three benefits of using constants:

1. You do not have to repeatedly enter the same value.

2. If you want to modify the constant value, you just need to modify the source code in one place.

3. Assigning a name to a constant that is known to the name increases the readability of the program.

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.