20145331 "Java Program Design" 7th Week study summary textbook Learning content Summary 12th Chapter LAMBDA
1. Lambda definition: A function that is not bound to an identifier and may be called.
2, in the case of only lambda expression, the type of the parameter must be written out, if there is a target type, if the compiler can infer the type of the case, you can not write out the parameters of the lambda expression type.
3. The reference object of this in the lambda expression and the recipient of ToString () are from the surrounding environment of the lambda, that is, to see the name of the lambda expression in the category, you can refer to the name within that category, such as a variable or method.
4. Lambda expressions are just one way to define function interface operations, and in addition, as long as the method signature of a static method is the same as the return value definition, a static method can be used to define the function interface operation.
5, lambda expression in parallel design, can be parallel processing.
The 13th chapter time and date 13.1.1 time measurement
1, Greenwich Mean Time (GMT) abbreviation GMT: by observing the sun.
2, Universal time (World) UT: By observing distant stars across the meridian.
3, International Atomic time (International Atomic Time) TAI: The Second international unit is defined as cesium atom radiation vibration of 9,192,631,770 weeks spent.
4, coordinated Universal time (UTC): Keep Tai and UT time error not too large with leap second correction.
5, Unix time with January 1, 1970 00:00:00 as the starting point
13.1.2 Calendar
1, Julian calendar (Julian calendar): fixed the Roman calendar three years to set a leap year error, the conversion of four years a leap.
2, Gergorian calendar (Gregorian Calendar): Reformed the Julian calendar, the Julian calendar on Thursday, October 4, 1582, the next day, set as Gregorian calendar October 15, 1582 Friday.
3, ISO 8601 Standard: The use of a unified data format.
13.1.3Time Zones
1.UTC offset: The accuracy is offset by 1 hours per 15 degrees, usually representing the z symbol.
2. The number of milliseconds in a year is not simple 3652460601000
13.2.1Date
Date: One way to get the system time is to use the System.currenttimemillis () method to return a long integer representing the number of milliseconds that have elapsed since January 1, 1970 0:0 0 seconds 0 milliseconds.
13.2.2DataFormat (formatted time date)
Dataformat:dateformat is an abstract class whose action class is Java.text.SimpleDateFormat, which can handle the string time format. You can format the various static methods of dateform, use the pattern string custom format, and use the parse () method to parse the specified string into a date instance.
13.2.3Calendar
Calendar:calendar is an abstract class, Java.util.GregorianCalendar is its subclass, manipulating the Julian calendar and Gregorian calendar of the mixed calendar, through the calendar getinstance () to obtain the calendar instance, the default is to obtain the GregorianCalendar instance.
13.2.4TimeZone
TimeZone's Getdefault can get information about the default time zone.
13.3.1 Machine Time View
The truly reliable information only contains the epoch milliseconds. You can also use the static method of instant now () to get an instant instance representing the number of milliseconds in the Java epoch.
13.3.2 Human Time Perspective
1.LocalDateTime: Includes date and time.
2.LocalDate: A datetimeexception error is thrown when a date is set to a date that does not exist.
3.LocalTime: Only time.
4.ZonedDateTime: Zoneddatetime automatically corrects when time-zone information is not actually present when it is combined.
13.3.3 the operation of time
For time measurement, the new time and date API is defined by class duration, which can be used to measure the difference in days, hours, minutes, seconds, precision adjustment can be Dana second level, and the maximum value of seconds can be a long type can be saved value. Use the period class definition for the date difference for the year, month, week, and day.
13.3.4 Calendar System Design
JDK8 Single calendar system design. If you need another calendar system, you need to explicitly implement a class that Java.time.chrono medium operation of the Java.time.chrono.Chronology interface.
Problems in code debugging and the resolution process
For time measurement, the new time and date API is defined by class duration, which can be used to measure the difference in days, hours, minutes, seconds, precision adjustment can be the Dana second level, and the maximum value of seconds can be a long type to save the value. For the time difference between year, month, week, and day, use the period class definition. Such as:
import java.time.*;import java.util.Scanner;import static java.lang.System.out;public class HowOld2 { public static void main(String[] args) { out.print("輸入出生年月日(yyyy-mm-dd):"); LocalDate birth = LocalDate.parse(new Scanner(System.in).nextLine()); LocalDate now = LocalDate.now(); Period period = Period.between(birth, now); out.printf("你活了 %d 年 %d 月 %d 日%n", period.getYears(), period.getMonths(), period.getDays()); }}
The results of the operation are as follows:
This week's code hosting
Other (sentiment, thinking, etc., optional)
This week's study is mainly the 12th chapter, the 13th chapter, the content is less difficult than before, and just take advantage of this opportunity to learn some of the previous knowledge, the interface, polymorphism and the exception of a solid learning, the first two parts have mastered (the exception still left a point not to read), knocking to understand the code feeling is still very good, Will upload the code as soon as possible.
Learning progress Bar
|
Lines of code (new/cumulative) |
Blog volume (Add/accumulate) |
Learning time (new/cumulative) |
Important growth |
| Goal |
3500 rows |
20 articles |
300 hours |
|
| First week |
150/150 |
1/1 |
14/14 |
|
| Second week |
150/150 |
1/2 |
14/28 |
|
| Third week |
100/400 |
1/3 |
14/42 |
|
| Week Four |
200/600 |
1/4 |
14/56 |
|
| Week Five |
317/917 |
1/5 |
14/70 |
|
| Week Six |
355/1272 |
2/7 |
16/86 |
|
| Seventh Week |
198/1470 |
2/9 |
16/102 |
|
Resources
- Java Learning Notes (8th Edition)
- Java Learning Note (8th Edition) Learning Guide
20145331 Java programming 7th Week of study summary