【读书笔记】Core Java for the Impatient 第一章
StringNever use the == operator to compare strings. The comparison
returns true only if location and "World" are the same object in memory. When comparing a string against a literal string,it is a good idea to put the literal
This test works correctly even when location is null. Input and OutputTo read a password,you do not want to use the Scanner class since the input is
The password is returned in an array of characters. This is marginally more secure LoopLabelyou want to jump to the end of another enclosing statement,use a labeled break statement. Label the statement that should be exited,and provide the label with the break like this:
A regular break can only be used to exit a loop or switch,but a labeled break can
The Enhanced for LoopYou can use the enhanced for loop with array and array lists.
ArrayListWhen that array becomes too small or is insufficiently utilized,another Wrapper Classes for Primitive TypesJust like with strings,you need to remember to call the equals method with Command-Line ArgumentsIf the program is called as
then args[0] is "-g",args[1] is "cruel",and args[2] is "world". (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |