A simple Java program example and several of its annotations

Source: Internet
Author: User

 Before talking about the subject, first to wordy two sentences, O () ^︶) O Alas, not to say that there is a lump in the heart, perhaps this is called obsessive-compulsive, well said I want to wordy, in fact, that is, about the Java Development Toolkit download and environment configuration. Java download into the Oracle official website to download (the specific steps will not repeat the network resources are now rich you know), download and then start the installation, according to the instructions in the installation process to the next step until the completion can, and so do not be excited, not yet, To start configuring the Java Development environment (which I'm talking about is just the window OS), it's also simple to open a window to the right mouse button on the desktop with the Click Property, and then into the environment variables under "advanced" in the "System environment variables" Set the following variable name and variable value:

Variable Name variable value

Java_home C:\Program Files (x86) \java\jdk1.6.0_22 (this is the path to Java when you install it yourself)

Path%java_home%\bin; (the value of the variable in path plus this, in fact this is to indicate when compiling and running the need to use the Java name, when you go to the Java installation path you installed you can see the command is under the bin directory)

classpath       .; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar in fact, the variable is configured to specify the location of the class (. Class) file that you are using in your program, and it is best to set the variable value as above without knowing it. Finally enter the DOS naming window and enter Javac–version, can appear to indicate success or failure. All right, wordy. Write a simple program to play:

1  Public class helloworld{23     Public Static void Main (string[] args) {45      System.out.println ("Welcome to Javaworld!!! "); 6 7    }89 }
View Code

Do not look at these lines of code, run its results will just print out the Welcome to the Java World!!!

In fact, contains a lot of content, the first is about the identifier in Java, the so-called identifier is actually the Java program's package, class, interface, variable or the name of the method, and Java to the identifier is a certain specification, is not a specification, that can be observed can not be followed, but the recommendation is best to abide by , after all, this is the accumulated experience of many years of programming. The naming conventions for their identifiers include the following:

The first character of an identifier must be a letter, an underscore "_", a dollar sign "$";

Identifiers are made up of numbers (0-9), uppercase letters (A-Z), or lowercase letters (A-Z), underscore "_", and dollar sign "$";

The identifier cannot be a keyword or a reserved field in Java;

Identifiers are sensitive to case comparisons, and Java is a strongly typed programming language.

The package name is usually the beginning of a lowercase domain, for example: Com.exercise ... A class or interface is usually composed of multiple words and capitalized on the first letter of each word, and the variable or method is generally composed of multiple words, with the first letter of the initial letter lowercase the other words in uppercase and the other letters lowercase; constant names all letters are capitalized and each word is best separated by an underscore or dollar sign.

Next contains the Java program's entry (Main method), each Java application has a portal, the main method can be overloaded, but the Java virtual machine only determines that public static void main (string[] args) {} The main method begins execution as a program.

Finally, there are a number of keywords public, static, void, class, for these key meanings will be in the following specific introduction.

There are three types of comments for the Java language, one-line comments that are not line-by-start comments, with "//comment content" to express, multi-line comments using the "/* Comment of the class */" notation, and a document comment with "/** comments * *", document comments can be used to automatically generate documents, It is important to note that in Java there is no nesting of multi-line annotations, that is, if the code province already has multiple lines of comments, then it cannot be enclosed in comments.

A simple Java program example and several of its annotations

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.