Now only to understand java8, is not after the understanding of the point?
New programming techniques, individuals do not like the first time to follow up.
Is it more cost-effective to have practice in the community?
A little shrewd Consideration. Not much to say, on the Code.
Read the note code for "java se 8" for busy people//i hope you're too busy to read this book, a quick glance, impress//wish programming Happy public class Maintest {//chapter i, speaking lambda Expression//lambda expression similar to J Avascript function literal, can be used to replace the Java anonymous inner class//basic type (formal parameter List)->{method body}, There are many shorthand methods, no redundancy//a method specifies the interface parameters, you can pass the lambda expression to the private static V OID C1 () {list<integer> l = arrays.aslist (1, 2, 3); function is Self-evident//foreach behind will speak, here face ripe l.foreach (i, print (i)); In addition, the interface can now declare the default method//so, the old interface + the default abstract class of the two declarations, can be combined to declare only one interface}//chapter ii, stream simplified collection using private static void C2 () {/ /filter, which can be understood as the WHERE clause of SQL list<integer> L = arrays.aslist (1, 2, 3); Long Bignumbercount = L.stream (). filter (i-i% 2 = = 1). Count ();//incidentally demonstrates aggregation print (bignumbercount);//2//projection , which can be understood as Sql's specified stream<integer> PlusOne = l.stream (). map (i-i+1); Plusone.foreach (i-print (i));//2,3,4//aggregation above has been demonstrated, can be understood as SQL Count/avg/max/min syntax//collection for {1:2, 2:3, 3:4} Dictionary map<integer, integer> result = L.streaM (). Collect (collectors.tomap (i-i, i-i+1)); Result.foreach ((k,v), Print (k + ":" +v));//by the way the lambda}//fifth, which demonstrates multiple parameters, tells the new DateTime API private static void C5 () { Date Localdate today = Localdate.now (); Print (today);//2016-08-15 localdate birthday = localdate.of (1988, 10, 31); Print (birthday);//1988-10-31//localdate Some practical methods such as Plusdays withdayofmonth//time localtime times = Localti Me.of (10, 31); Print (time);//10:31//localtime Some practical methods such as Plushours withminute//datetime LocalDateTime dateTime = localdate Time.now (); Print (dateTime);//2016-08-15t21:46:01.719//date to string, using default format print (DateTimeFormatter.ISO_DATE.format (birthday)) ; String to date, using the custom format datetimeformatter myformatter = Datetimeformatter.ofpattern ("yyyy". Mm.. DD "); Localdate fromstr = (localdate) localdate.parse ("1988..10..31", myformatter); Print (fromstr); Oldclass with old date date = Date.valUeof (birthday); Localdate Newclass = oldclass.tolocaldate (); }//miscellaneous improvements to private static void C8 () {//string add join String Whoishero = string.join (",", "caocao", "liu bei", "sun Quan "); Print (whoishero); iterable add foreach arrays.aslist ("guan yu", "zhang fei", "zhao yun"). foreach (i-and print (i)); Easy to read the file contents path Path = Paths.get ("/juqiuwang_logs", "juqiuwang.log");//by The way, show path using try (stream<string> lines = Files.lines (path)) {//by the way the demo automatically closes the resource Lines.foreach (s-to print); }catch (Exception e) {throw new RuntimeException (e); }}//JAVA7 attribute private static void C9 () {//auto-close Resource's try (xx) notation in C9 has been shown//path in C9 also used//easy to read files Content try{list<string> lines = files.readalllines (paths.get ("/juqiuwang_logs", "juqiuwang.log")); Lines.foreach (s-to print); Files There are also some practical methods, not}catch (Exception e) {throw new RuntimeException (e); } } public static void main (string[] Args) {c1 (); C2 (); The 3rd chapter is about the application of lambda, please read//4th chapter about javafx, such as interested please read C5 (); The 6th chapter is about concurrency, such as interested please read//7th chapter about JavaScript engine, such as interested please read C8 (); C9 (); } private static void print (Object O) {System.out.println (o); }}
Java SE 8 notes for busy people