您的位置:首页 > 编程语言 > Java开发

CORE JAVA study note(CHAPTER THREE)

2015-07-27 14:12 525 查看
1. File Input and Output

Scanner in = new Scanner(Paths.get("c:\\mydirectory\\myfile.txt"));

PrintWriter out = new PrintWriter("myfile.txt");

caution: scanner interprets the strings as data not a file name.

java.util.Scanner

Scanner(Path p)

constructs a Scanner that reads data from the given path.

Scanner(String data)

constructs a Scanner that reads data from the given string.

java.io.PrintWriter

PrintWriter(String fileName)

constructs a PrintWriter that writes data to the file with the given file name.

java.nio.file.Paths

Static Path get(String Pathname)

constructs a Path from the given path name.

2. Control Flow

when you use the SWITCH statement whit enumerated constants, you need not supply the name of the enumeration in each label——it is deduced from the SWITCH value

labeled break: you can only jump
out
of a block never into a block

3. Big Nnumbers

Use the static valueOf method to turn an ordinary number into a big number

Use add , multiply and so on to operate on big numbers!

4. Array

String[] names = new String[10];    creates an array of ten strings, all of which arenull. if you want the array to hold empty strings, you must supply them

:   for (int i = 0; i < 10; i++) names[i] = "";

CAUTION: YOU CAN'T INCREMENTA TO POINT TO THE NEXT ELEMENT IN THE ARRAY.

command-line parameters :    the name of the program is not stored in theargs array!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java