Java beginners (1) 1. Introduction and basic features
Category: java Basics
1,Why is java so popular? Why did history choose it?
Because it has a brand new programming idea and is closer to people's language habits, because its compiler compiles the code into bytecode, then run on different platforms and use different virtual machines to explain bytecode, so that the same source program can run on platforms that are not used, or C ++ runs fast, but the intermediate form of interpretation is the foundation of its development.
2,What are the characteristics of java programs?
1. completely object-oriented.
2. The minimum program unit is class. (But the class can have its attributes and methods)
3. There is only one public class in a source program, which can also be omitted.
4. Each source program must have an execution entry: pubic static void main (String [] args ).
5. Make necessary comments: // (single row )//(Multiple rows )/*/(Document comment) --> document comment can be used
The Javadoc command generates your own API documentation, that is, the instruction manual for the defined class. It should be placed in the class definition before the method.
6. The file storage extension of java is (. java), when the java source file has a public class, the main file name of the source file must be consistent with the public class name; when the source file does not have a public class, the file name can be arbitrary.
3,* Common doscommands?
1. Compile the java source code command: Javac-d [Directory] [java source file]
-D Indicates destination, which indicates the target to be opened.
Directory: the directory in which the generated binary bytecode is stored.
Note: The number of classes defined in the java source file will generate the corresponding number of class files. The source program can only have one public class.
2. Run the java program: java-cp [Directory] [java class name]
-Cp indicates the classpath, that is, the storage path of the class.-cp [Directory] indicates that the corresponding class is searched and executed under this directory.
It can also be replaced by ".", which indicates searching in the default directory.
Java class name: that is, the name is added with. class.