Write the first java program and the first java program
I installed an editor, Notepad ++, which I used to use when I was writing PHP. Now I will keep this editor when I write java.
Code:
Public class Test {public static void main (String [] args) {System. out. print ("Hello! "); // Output java }}
According to the current understanding:
System. out. print (); this is the output statement.
System. out. println (); this is a line feed output statement.
Each class name must be the same as the file name; otherwise, an error is returned.
Each file must be written in the above main frame, that is, the above Code. In addition to the output statement, the specific reason is to write it like this, so I will understand it later.
JAVA is case sensitive, so be sure to pay attention to it.
JAVA annotations, which are the same as js and Php. // The double slash is a single line annotation, And/**/is a multi-line annotation.
JAVA is developed by sun and is divided into three major systems: java se (for desktop development), java ee (for web development), and java me (for embedded development, such as mobile phones, small Household Appliances)
After the code is written, save it as a file named Test. java (the suffix of java is. java), save it to the E disk, and open dos.
Enter e: Press enter to switch to the edisk.
Enter javac Test. java Press enter. Execute this doscommand to compile the java file, Because java is to be compiled into binary before execution. After compilation, a same file name, different suffix, and suffix will be generated in the directory at the same level. class compilation file. Now the Test. java file has been compiled and can be executed.
Enter java Test and press enter to run the Java program. The above code will output Hello!
In the string, input \ n is a line break, and input \ t is a Tab.
Public class Test {public static void main (String [] args) {System. out. print ("Hello! "); // Output Hello! System. out. println ("Hello! "); // Output Hello !, Line feed System. out. print ("\ tHello! "); // Tab output Hello! System. out. print ("\ tHello! \ NHello2! "); // Tab output Hello !, And line feed output Hello2! }}
Shows the output result.