Examples of my Java programs show

Source: Internet
Author: User

My first Java program
Here we show Java programming through a simple example, creating a file Helloworld.java (the filename needs to match the class name) with the following code:
Instance
public class HelloWorld {
public static void Main (string[] args) {
System.out.println ("Hello World");
}
}


Note: String args[] and string[] args can be executed, but it is recommended to use the string[] args, which avoids ambiguity and misreading.
Running the above example, the output is as follows:
$ Javac Helloworld.java
$ Java HelloWorld
Hello World
To perform a command resolution:
Above we used two commands Javac and Java.
Javac is followed by the file name of the Java file, such as Helloworld.java. This command is used to compile the Java source file into a class bytecode file, such as: Javac Helloworld.java.
After running the Javac command, a helloworld.class file appears if there is no error in compiling successfully.
Java followed by the class name in the Java file, such as HelloWorld is the class name, such as: Java HelloWorld.
Note: Do not Add. class after the Java command.

Examples of my Java programs show

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.