20165230 2017-2018-2 "Java Program Design" 2nd week study summary Textbook study summary
- This week we learned about data types, arrays, operators, expressions, and statements in Java, similar to the C language, and there are differences.
- Letters in identifiers are case-sensitive
- Java does not have unsigned bit byte,short,int,long
- The floating-point compiler defaults to double, which must be followed by an F after declaring the float variable.
- Char data in Java must be unsigned, and unsigned is not allowed to declare char types
- You cannot specify the number of array elements within square brackets when declaring an array
- Index of array starting from 0
Problems in teaching materials learning and the solving process
- Question 1: Why double 123456789.123456789 cast to single precision is 1.23456792E8 instead of 12.3456792E8
Problem 1 Solution: F=1.23456792e8 is equivalent to moving the 123456789.123456789 decimal point forward into 1.2345678912345678910^8, minus half of the decimal to become 1.2345678910^ 8,
- If you want to control the error, you can use STRICTFP. When declaring a method with the STRICTFP keyword, all of the float and double expressions in the method adhere strictly to the fp-strict limit and conform to the IEEE-754 specification.
When using the STRICTFP keyword on a class or interface, all code in the class, including the initial setpoint and code in the nested type, is evaluated Strictly. Strict constraints mean that the results of all expressions must be the result of an IEEE 754 algorithm's expected operand, expressed in single-precision and double-precision formats.
If you want to make your floating-point arithmetic more accurate and not inconsistent with the results of different hardware platforms, you can use the keyword STRICTFP.
- The question 2:p28 page mentions that if you want to output a reference to a char array, you must have the array A and string collocated, what is the collocated operation?
Problem 2 Solution: on-line queries get the following answers:
Collocated "&" is the connection operation for bit and bit vectors.
The so-called bitwise-and-bit vector connection operation refers to the contents of the right side of the collocated operator after the contents of the left to form a new bit vector
Reference: collocated statements
- Question 3: The method of not understanding the number of primes within the Example3_7.java 100
- Problem 3 solution: Through their own debugging code and ask the classmate understand the code, if the number of primes within 100, there is a method for starting from 1 and the square root 100 to take the modulo operation, if the remainder is not 0, is the prime number. This code is similar, just with 100/2 to take the modulo operation, and then to find the remainder.
Problems in code debugging and the resolution process
- Issue 1: An internal error appears when you start the Bantu system
- Problem 1 Solution: By looking in the Web, find the solution for the terminal input to
sudo gedit /etc/default/apport
set the enabled to 0.
Refer to Ubuntu16.04 system error Reporting masking attempts to modify
Issue 3: When debugging example2_5, repeated checks repeatedly and the following error appears, the symbol is not found
.
- Issue 3 Solution: by re-examining the code discovery is to put
Scanner scanner = new Scanner(System.in);
the second scanner in the less input a C.
Issue 4: When debugging Example3_4, enter 209 display 209 is both the second and first prize
- Problem 4 Solution: There is no sentence after the second prize plus break;
Issue 5: Error when debugging example3_9, incorrect capitalization of system in SYSTEM.OUT.PRINTLN
Issue 5 Solution: correct system to System
Code Hosting
Other (sentiment, thinking, etc., optional)
- In this week's study, the code volume is more than last week, the understanding of the code is deepening, at the same time, the error rate of knocking code is reduced, usually hit the code when the case, space and other details.
- Through self-study video and teaching materials, analogy C language to the basic data types in Java, statements have a understanding of the process encountered problems through the network query and ask students one by one to solve.
Learning progress Bar
|
lines of code (new/cumulative) |
Blog Volume (Add/accumulate) |
Learning Time (new/cumulative) |
Important Growth |
Goal |
5000 rows |
30 Articles |
400 hours |
|
Second week |
426/426 |
3/3 |
12/12 |
|
Resources
- "Java2 Practical Course (Fifth Edition)" Learning Guide
- Tips for how to turn off internal errors, system programs, and problems with Ubuntu
- collocated statements
- Java Data type conversions:
20165230 2017-2018-2 "Java Programming" 2nd Week study Summary