Basic syntax for Java

Source: Internet
Author: User

Java language is strictly case sensitive

Multiple classes can be defined in a Java source file, but only one of the classes is defined as the public class

If the source file contains the public class, the name of the source file must be the same as the public class

public class Test{public static void Main (string[] args) {System.out.println ("Hello world!");}}

Compile

If the name is inconsistent, the error will be

When a source file contains multiple classes, a successful compilation generates a corresponding number of bytecode files, that is, each class generates a separate class file, and the byte-code file name is the same as its corresponding class name

public class Test{public static void Main (string[] args) {System.out.println ("Hello world!");}} Class A{}class B{}class c{}

Compile

If a class must run, you must have the main method, because the main method is the primary entry of the program

Programming Recommendations:

A Java source file defines only one class, and different classes use different source file definitions

Defines the individually defined classes in each source file as public

Keep the Java source file name consistent with the class name in the source file

Basic syntax for Java

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.