等号右边是Lamdba表达式,等号左边是作为Lamdba表达式的目标类型。(String name1,String name2)->name1.length()-name2.length(); 表示接受两个字符串型参数name1,name2,而->右边定义了会返回结果的表达式。
管道操作风格 来源:可能是文档、数组、群集、产生器等等。中间操作(0或多个):又称集合操作,调用时,并不会立即进行手边的数据处理,只会在后续中间操作要求数据时才会动手处理下一笔数据。最终操作(1个):最后真正需要结果的操作,会要求之前的中间操作开始动手。第十三章 时间与日期 Calendar Calendar是个抽象类,java.util.GregorianCalendar是其子类,操作了儒略历与格里高利历的混合历,通过Calendar的getInstance()取得的Calendar实例,默认就是GregorianCalendar实例。两个文件的代码差别在于Demo中是
class Hello { Runnable r1 = new Runnable() { public void run() { out.println(this); } }; Runnable r2 = new Runnable() { public void run() { out.println(toString()); } }; public String toString() { return "Hello, world!"; } }Demo2中
class Hello2 { Runnable r1 = () -> out.println(this); Runnable r2 = () -> out.println(toString()); public String toString() { return "Hello, world!"; } }为什么只是写成了Lamdba表达式,运行结果就不一样了?
问题1解决方案:因为Demo中this的参考对象和toString()的接受者,是Runnable实例,而Runnable的toString()并没有定义,所以显示了Object默认的返回字符串。而Lamdba表达式中this的参考对象和toString()的接受者,是来自Lamdba的周围环境,即表达式在哪个名称范畴,就能参考该范畴内的名称。A .1 B .2 C .3 D .4 错误原因:忘记main主线程,答案应该是C三个线程。
调用线程的interrupt()方法 ,会抛出()异常对象?DE A . IOException B . IllegalStateException C . RuntimeException D . InterruptedException E . SecurityExceptionWhich of the following statements about the Callable call() and Runnable run() methods are correct? (Choose all that apply.) ADE A .Both can throw unchecked exceptions. B .Callable takes a generic method argument. C .Callable can throw a checked exception. D .Both can be implemented with lambda expressions. E .Runnable returns a generic type. F .Callable returns a generic type. G .Both methods return voidWhat are some reasons to use a character stream, such as Reader/Writer, over a byte stream, such as InputStream/OutputStream? (Choose all that apply.)ACA .More convenient code syntax when working with String data
B .Improved performance
C .Automatic character encoding
D .Built-in serialization and deserialization
E .Character streams are high-level streams
F .Multi-threading support
Suppose that the file c:\book\java exists. Which of the following lines of code creates an object that represents the file? (Choose all that apply.) BCA .new File("c:\book\java");
B .new File("c:\book\java");
C .new File("c:/book/java");
D .new File("c://book//java");
E .None of the above
看教材第十二章管道操作部分的时候,感叹于管道操作的高效率性和便捷性,但也有种无力感,因为感觉自己还是个新手,不能熟练掌握这种编程模式,可能编程的时候脑子都会乱……。感觉十三章内容非常有意思,还学习了各种事件的度量。
计划学习时间:18小时
实际学习时间:20小时
改进情况:多学习了两个小时
Java学习笔记(第8版)
《Java学习笔记(第8版)》学习指导Java中的L是什么
转载于:https://www.cnblogs.com/zhuohua/p/6685750.html
