#1. Summary of the study in this chapter
①java Basic data types
The ②string class object uses
#2. Written work
- Associate the JDK source code with Eclipse and view the source () of the string object? What does the parsing string use to store strings? How do you analyze the implementation of the constructor function
public String(char value[]) ? The public String replace(char oldChar, char newChar) implementation principle of the analysis, how to answer the immutability of the string in this function how to embody? Focus string is a string constant that cannot be modified after the instance is created.
2. Why should I try to modify the string as frequently as possible by using StringBuilder instead of string?
When a string object needs to be added, it produces multiple objects, and using StringBuffer is significantly more memory-saving than using string when building the strings, because it produces only one object
3. Compare the values of two strings for equality? Why can't I use = = to compare directly?
If you use string directly, the code at run time, also need to do object type conversion, create new objects and so on, not only waste computing resources, reduce the efficiency of operations, but also occupy the extra memory space.
Comparison of strings equal should be used. Equals () method
4. Try using the concept of a string pool to interpret the output of the following program segment and answer this code to create several string objects:
String str1 =“hi“, str2=“hi“;String str3 = new String(str1)System.out.println(str1==str2);
因为str2的字符串常量与str1一样,因此str2->str1,所以以上程序运行结果为:true;这段代码创建了两个字符串对象,str3指向一个,str1与str2指向一个。
5.Integer i = 100;//100 is the base type, I is the reference type, why I can be assigned to 100
Since 100 is a basic data type, in principle it cannot be assigned directly to an object integer, but after jdk1.5 you can make such a declaration, which is automatic boxing,
Automatically converts the base data type to the corresponding package type. All of the methods declared by the object can be called after being an object
6. Try to analyze the following code output results
127;Integer i2 = 127;i1 == i2;//true of false?Integer i1 = 128;Integer i2 = 128;i1 == i2;//true of false
第一个是true,第二个是false。127在-128~127之间,所以为TRUE,128大于这个范围,比较的是地址。
7.1 Try to compile and run with the command line,
7.2 Put the generated stringutil.class under the correct directory structure under D:\lib, put the main.class into the correct directory structure under D:\test, try to run under the command line, and.
7.3 Where is the source code in Eclipse and which directory is the class file placed in? Just click on the Eclipse project to Ctrl+F11 Run main, what kind of java command was executed in which directory when CTRL+F11 was pressed? Meow meow meow ...?
Own goals and plans in this course
Please describe your technical basis (what language, how many lines of code written)
How much time are you going to spend in this class in a week? How many lines of code are you going to write a week? What type of learning is used? How do you plan to solve the difficulties?
Ern (Serious face
#3. PTA Experiment Summary and code-on-Cloud codes submission record
201521123088 Java Program Summary of the second week