Write the first Java program using MyEclipse
Then right click on src to create Class
/*** Package: Statement of Packages! * Represents the location of our current Java source files in the project! * Must be in the first line except for comments! * and only one package declaration is allowed in the entire Java source file! */ Packagecn.bdqn.test;/*** Document Comments (JAVADOC) *@authorSmall Tofu * This is the first Java program I created using the myeclipse development tool * * Comments in Java: * 01. Document Comments * 02. Multiline Comment * 03. Single-Line Comment * * * Note purpose: * 01. Easy to use within the team People's Reading * 02. Facilitate post-Project maintenance * * We must develop the habit of writing notes! *//** Multi-line Comment*///single-line comment/*** Public: access Rights! The most loose one! The public! * Class: Classes! is the smallest unit that forms our program! * HelloWorld: Class name! Must match the name of the Java source file! * {}: Must appear in pairs, there is a start, there is closure! * * Compare HelloWorld to a home, then the code written in {} is our home furniture! * Then the furniture can be understood as main () * Furniture can also store many items! * Items can be understood as our code! * How to use items? Run the Java Project! */ Public classHelloWorld {/** * @paramparameters that are carried by the args method * * static: Modifier! * Void: Represents the method return value type! If the method does not return a value, it must be written as void! * Main: Name of the method * String []: type of parameter * args: Name of parameter*/ Public Static voidMain (string[] args) {/*** Alt +↑/↓ Move up/down the code where the cursor is located * ctrl+alt+↑/↓ the code where the cursor is copied up/down*/System.out.println ("Everyone is so hard."); }}
/**Documentation Comments * There are three types of java annotations * 01. Documentation Comments * 02. Multiline Comment * 03. Single-Line Comment * * Objective: To facilitate the staff of the team to read! * You have now written a small program, did not write comments! 1 months later you are looking at your program! * * Package Name specification: * 01. Domain name inversion cn.bdqn.d domain name d.bdqn.cn * 02. Full lowercase * 03. Prevent class Name collisions * Package: Declares the location of the current Class! There can be only one package declaration in a Class! * Must be in the first line except for comments! * * Javac: Compiler converts Java files to class file * Xjad: Decompile tool! Convert a class file to a Java file * * * Hump naming: FirstName The first letter of the variable name, followed by the meaning of the first letter of the word also uppercase * Pascal nomenclature: (Big Hump) class name FirstName the first letter of capital, then the meaning of the first letter of the word must also be capitalized * * SYSTEM.OUT.PRINTLN (); After outputting a statement, the line wrapping is equivalent to \ n * System.out.print (); does not wrap automatically * \ t space \ is the escape character in Java * * System.getproperty ("User.dir"): Gets the working directory of the user's current project * Public: Access modifier access rights Maximum * class: The Representation of class * static: Static! You can modify the method, properties, and code block * Void: The return value of the method! No return value must be written on void * Main (): Method name * string[] args: Parameter * string[]: type of parameter * args: Parameter name*/ PackageCn.bdqn.test;//HelloWorld the package in which this class resides Public classHelloWorld {//single-line comment Java program entry Public Static voidMain (string[] args) {System.out.println ("Good afternoon, everyone!");//Output StatementSystem.out.println ("Good afternoon, everyone!") "); System.out.println ("Project Current working directory:" +system.getproperty ("User.dir"))); }}First Java
Java Fundamentals 02