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!
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对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- 插入排序
- 冒泡排序
- 堆排序
- 快速排序
- 二叉查找树
- [原创]java局域网聊天系统