First knowledge of Java

Source: Internet
Author: User

First, install the JDK
Download a JDK, install it, and remember the path to the installation
Second, the Environment configuration
This computer--properties--Advanced system settings--environment variables
New system Variable: variable java_home value: C:\Program files\java\jdk1.8.0_11
If this is not successful, you can add the path variable to the user variable with the value: C:\Program files\java\jdk1.8.0_11

Third, build a Java file with a text document
Write a HelloWorld
1. Create a new text document, named HelloWorld, and write the following code in the document:

1 public class helloworld{   2 public     static void Main (string[] args) {  3         System.out.println ("Hello World !");   4     }5}

2. Change the suffix name of the text document to. java
3.windows+r input cmd
Input g:g refers to the file stored in the G disk
Enter Javac Helloworld.java to compile the code you write
Enter Java Hellowworld run

Iv. Building a Java file with eclipse
Build a Java project first, then create a new package in SRC, and then create a new class.
1. Name of the package: COM. company name. XXX
New Project: File--new--java Project
New package: SRC Right-click--new--package
2. Class naming: The class name must be consistent with the file name
New class: Package right button--new--class
3. Code writing:
Write the following code:

1 package com.jerehedu.ch01; can automatically generate 2 3 public class HelloWorld {   //can automatically generate 4 public     static void Main (string[] args) {5         System.out.println (" Hello world! "); 6     }7}


Here are some things to keep in mind:
       alt+/Quick Tips
        The main method is the execution entry for the Java program;
   each Java file can have at most one main method;
     four elements of main: public static void parameter, Integral!
     println: After you have printed the contents of "", wrap the text automatically;
  \ n line break also use
  \ t tab, tab to return the cursor to the next tab stop. One tab stop eight characters
     bin holds compiled    executable bytecode file
  SRC holds Java source file
Comments: Comments have single-line comments, multiline comments, and Document Comments
        single-line comment: //
        Multiline comment: /*  explanation of code  
        Documentation Comments:/**   compared to multiple lines of comments,  When commenting on a method with a document comment, the mouse points to the method name, and you can see the canonical content of the

code for the comment:
       class name using the public modifier
   Write one line of code
   {} format, note one by one for
    Note indent

 

First knowledge of 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.