Java Learning Diary num2

Source: Internet
Author: User

Learning content: keywords, identifier naming rules and Java naming conventions in Java, constants and variables; Select Structure if switch

First, the key word

1, the keyword used to define the access rights modifier

(1) Private (2) protected (1) public

2, keywords for defining classes, functions, variable modifiers

(1) abstract abstraction (2) final (3) static statics (1) Synchronized synchronization

3, the keyword used to define the relationship between classes and classes

(1) extends Inheritance (2) Implements implementation

4, to define the instance and reference instance, to determine the keyword of the instance

(1) New Creation object (2) This class (3) Super Parent class (4) instanceof judge the same

5, keywords for exception handling

(1) Try Check (2) Catch handling (3) throw throws in function with object (1) throws throws on function with exception class

ii. Identifier naming conventions and Java naming conventions in Javanaming rules for identifiers in 1,java

(1), identifiers consist of 26 English case, 0 to 9, and underscore "_" and dollar Sign "$"

(2), the name of the identifier cannot begin with a number, you cannot use a keyword in Java

(3), identifiers in Java are strictly case-sensitive.

2,java Naming Conventions

(1), the package name unified for no matter how many words, unified for lowercase for example: xxxyyyzzz

(2), class name and interface name capitalize the first letter of each word for example: xxxyyyzzz

(3), function name and variable name the first word is lowercase, if more than one word starts with the second word, the first letter of each word is capitalized for example: Xxxyyyzzz

(4), the name of the constant, each letter of each word is capitalized, and the words are connected using an underscore example: Xxx_yyy_zzz

three, constants and variables1,java Constant Classificationinteger constants: For example, 4Decimal constants: For example 54.34Boolean constant: evaluates to TRUE or False for example truecharacter constants: Use single quotes such as ' C 'string constants: Use double quotes such as "AFGD"NULL constant: The value can only be null, such as null 2, variablevariables are the storage of uncertain data, that is, the need to open a space in memory

IV. Select Structure if switch

1,if Statements

format:

if (conditional expression) if (conditional expression) if ( conditional expression)

  Statement                statement                           statement

else else if (conditional expression)

statement statement /c15>

                                        ......

                                       else

                                        statement

2,switch

1,switch can only receive Byte,short, Int,char-type data behind. The enumeration can be accepted after JDK5.0, and the string can be accepted after JDK7.0.

the 2,case option and default have no order. Regardless of the default in the first position, the middle position, the end, does not affect the final judgment.

3, two scenarios for ending a switch statement: Encountering a break or executing to the end of a switch statement

4, if the matching case or default does not have a corresponding break, then the program will continue to execute down, run the statement that can execute until the break or switch end is encountered.

  

Java Learning Diary num2

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.