Java Basics (i)

Source: Internet
Author: User

1.//

2.//helloworld Application Examples

3.//

4.public class helloworldapp{

5. public static void Main (string[] args) {

6. System.out.println ("Hello, Welcome to my Blog")

7.}

8.}

Description Helloworldapp

Row

Lines in the program are comment lines

Line 4th

Line 4th declares that the class name is Helloworldapp. The class name (CLASSNMA) is indicated in the source file, and he can create a classname.class file on the same directory as the source code. In the above code, the compiler creates a file called Helloworldapp.class, which contains the compiled code for the public class Helloworldapp

Line 5th

Line 5th is the entry of the program, the Java interpreter must trigger this defined point, otherwise it will refuse to run the program (very wayward, grumpy)

If any arguments (command-line arguments) are given in the program's command line, they are passed to the string array called Args in the main () method. In the above code, the arguments are not used

public--Description Method Main () can be accessed by any program, including the Java interpreter

static--is a keyword that tells the compiler that main () is a method used in class Helloworldapp. This keyword is necessary in order for main () to start running before the program does anything else

void--indicates that main () does not return any information. This is important because the Java programming language has to be cautious about type checking, including checking that the calling method does return the type of these method lock declarations

String args[]--is an array declaration of a string type that is the parameter of the Main method, which will contain the arguments in the command line after the class name

{}--Two curly braces together the middle of the content is called the method body, which represents the code executed by this method

Line 6th

Line 6th declares how the class uses the class name, object name, and method invocation. It uses the println () method of the PrintStream object that is referenced by the out member of the system class, and the string "Hello, Welcome to my Blog" prints to standard output

Line 7th to 8th

The 7th to 8th line is the next parenthesis of the method main () and class Helloworldapp, respectively

Java Basics (i)

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.