Objective
The second week is a formal study of Java programming. Before the Java is a blank, now is the first clue, know the basic Java program start, more than one class to run which, which is output printing statements and so on.
The Java code writer I'm using now is Atom
an Atom
Github
open source text editor, built entirely using web technology (based on Node-webkit). Fast startup, with a lot of common functions of the plug-ins and themes, can be said to be Atom
sufficient for the "half of the IDE."
Compared to Notepad and Linux system vim
, and gedit
so the editor Atom
is very smart, different features different properties of the code color different to show the difference, and even can complement the code (but this function after the proficiency of later use, now is to practice more dozen code to write down the basic format and statement).
Atom
can also be the system to manage the entire large folder under the numerous folders and files, you can at the side of the sidebar at a glance in the Code folder under what folders and files, code Open switch is also very fast. Recommended, Windows subsystem is installed directly under Windows and then opens Atom
open project
in the C disk to find your own subsystem folder (in my own case C:\Users\wyhy-(computer owner user name, specifically find his own name) \appdata\local \packages\canonicalgrouplimited.ubuntuonwindows_79rhkp1fndgsc\localstate\rootfs\home\yhooyon (my Ubuntu system name, Specifically find their own) to find their own user folder to find the SRC folder to store the code to manage their own code.
Textbook Learning content summary identifiers and keyword identifiers
A valid sequence of characters used to identify the class name, variable name, method name, type name, array name, and file name is called an identifier, and the identifier is a name.
Java Rules for identifiers:
Basic types in Java
- Integer: Can be subdivided into short (2 bytes), int (4 bytes), Long (8 bytes)
- BYTE: Byte, if used to represent an integer, a byte can represent an integer of -128~127
- Floating point number: Mainly used to store fractional values, can be divided into float (4 bytes) and double (8 bytes)
- Characters: char, kanji, English characters are double-byte, java character encoding is Unicode
- Logical Type: Boolean
Type conversions
Type many times the compilation does not pass, it may be that these details are not noticed. In Java, the variable type is very strict, in the case of unspecified, the integer is generally int type, the decimal is the default double type, if you do not pay particular attention to these are easy to err, for example: float PI = 3.14,3.14 default to double type, you can not assign a double type of decimal to float type, this will lose precision, compile error.
Input and output data input basic type data
Scanner is a new class that SDK1.5 adds, but uses this class to create an object.
Scanner reader=new Scanner (system.in);
The reader object then calls the following methods (functions) to read the various data types that the user entered at the command line:
next.Byte(),nextDouble(),nextFloat,nextInt(),nextLine(),nextLong(),nextShot()
The above method will cause a blockage when executing, waiting for the user to enter the data return confirmation at the command line. For example, the value of 12.34,hasnextfloat () that advocates on keyboard input is true, and the value of Hasnextint () is false. Nextline () waits for the user to enter a line of text and enter, which gets a string type of data.
Output Basic type data
System.out.println () and System.out.print ()
You can enter the value of a string value, an expression, the difference is that the former output data after the line, the latter does not break the line. Allows you to use the collocated symbol + to output a variable, an expression, or a constant value with a string.
Format Control characters:
- %d: output int type data
- %c: Output Char type data
- %f: Output floating-point type data with a decimal point of up to 6 digits.
- %s: output String type data.
- %MD: Output int type data in M column
%M.NF: Output floating-point type data is in M-column and the decimal point remains n-bit.
Operator
- The characteristic of,&& in the logical operator is that if the left of && is false, the logical judgment of the return result is false regardless of the right truth.
The Same, | | is characterized by the fact that if | | On the left is true, the logical judgment of the return result is true regardless of the right truth. This, to a certain extent, can improve the efficiency of code compilation and execution.
In the increment, decrement operator, it is important to note whether the operator is placed on the left or right side of the variable, if the operator is on the left side of the variable, then the variable value is changed before the operation, if the operator is to the right of the variable, then the first operation and then the corresponding addition and subtraction of the variable.
StatementIf...else Conditional type
It is important to note that the executed statement is enclosed in curly braces, otherwise, the default is to only execute the first sentence after if.
Switch conditional type
switch有点像多个分支的if语句,但在某些情况下,用switch可以提高代码的效率,书本上也有相应的例子,不用进入每个if语句去判断,可以通过待判断的值直接进入相应的case,只是注意switch一般都会配以break一起使用,编写代码时不能忘记这一点。
While loop
当型循环:while(条件式){描述句},先判断条件式的布尔类型,如果成立,则执行描述句。直到型循环:do{描述句}while(条件式);,特点是先执行一遍描述句,再判断条件,如果条件成立就再执行一遍描述句,直到条件不成立为止。需要注意的是:while的两种类型的区别,在写法上,注意当型while后没有分号,第二种有分号。break continuebreak:结束当前循环。continue: 跳过当前循环一次。break、continue还可以和标签一起配套使用。break与标签配套时,则结束该标签包含的所有语句;continue与标签配套时,则跳过该标签包含的所有语句。
Problems in teaching materials learning and the solving process
On println
print
printf
the difference with
print--is a function that returns a value that can have only one argument, displays its arguments in the command window, and positions the output cursor after the last character displayed.
- The only difference between println--and print is the println output, which displays its parameters in the command window and adds a newline character at the end, positioning the output cursor at the beginning of the next line.
printf--function, the text format after the output, the direct call system calls for IO, he is non-buffered.
Code Hosting
Sentiment
The most important thing to learn a program language is more practice, first of all, even if you do not understand the code, can only look at other people's code to play, see more gradually will understand, at least understand the basic framework of the language, how to start, how to describe, what is the routine. After that, the program will be able to fully understand the meaning of the code.
Learning progress Bar
|
Code lines (new/cumulative) |
Blog volume (new/cumulative) |
Learning Time (new/cumulative) |
important growth |
Goal |
5000 rows |
30 Articles |
400 hours |
|
First week |
200/200 |
1/4 |
10/10 |
|
Second week |
300/500 |
1/5 |
10/20 |
|
Third week |
|
|
|
|
Week Four |
|
|
|
|
Take a look at the Java Practice Tutorial Learning Video
Resources
Java Learning Notes (8th Edition)
- Java Learning Note (8th Edition) Learning Guide
The difference between print, println, and printf
20165231 2017-2018-2 "Java Programming" 2nd Week study Summary