20165235 Qi Ying Java second week exam summary after class exercise p16
- Code writing
class Person {void speakHello (){System.out.print("nin hao ");System.out.println("nice to meet you"); }} public class Xiti { public static void main (String arg[]){ Person zhang = new Person(); zhang.speakHello();}}
Understanding of the subject: Because this code originally the main class name is person, so I changed the code, put the main class on the Xiti, compile it javac Xiti.java
and run the java Xiti
result as follows
Test P14 of textbook code completion
- This topic let us in unbuntu with their own school number to create a folder, and the textbook 14 pages of Kernighan saved as a Java file, and compiled run, this program is used to calculate 1 to the number of four digits after the sum of the following is the program run:
Understanding of the Subject: This topic is to achieve a large number of sums, so I think it should be changed in the code int sum
long sum
, if the last data bit too long will result in distortion.
Code compilation with package run test-In Ubuntu or Windows command line, build the following directory structure (refer to the accompanying drawings)
2016XXXX (School number)
Src
Hello.java
Bin
The contents of the Hello.java are shown in the annex
Package isxxxx; (xxxx is replaced by your four-digit number)
Compile run Hello.java, submit run result, to full screen
- Do git add in class; git commit, push code git to the code cloud in class
- The running results and directory structure are as follows:
Understanding of the subject: the main test of this topic is the establishment of the file directory, use mkdir src
, and mkdir bin
build src and Bin file directory. Then write the code in SRC with the Vim editor, Mark at the top of the code, package is5235
and return to the 201652_35 directory using the command javac -d bin src/Hello.java
to have the Hello.java compiled file in the bin, java -cp .:bin is5235.Hello
Package the Hello.class file into the folder is5235 and run it at the same time.
Exam Summary
This exam failed to submit three questions, there is a poor network reasons, but also I am slow action reasons, I hope the next exam can be better. Above the understanding of the problem may be wrong place, I hope the teacher, learn a lot of help.
2018-03-11 20165235 Qi Ying Java second Week exam summary