4.ArrayList能处理大数据的加减,范围与int,long相比更广
2. Written assignment 1. string-using eclipse to correlate JDK source code1.1 View the source code () of a string object and analyze what string is used to store strings?
String strings are constants that cannot be modified after they are actually created, which are character arrays
1.2 Analyze the function of its constructors public String(char value[]) ?
The main purpose of the function is to construct a string object with a char array str
1.3 Read the public String replace(char oldChar, char newChar) code of the method, and answer how the immutability of the string is reflected in the function? Focus
The original string will be regenerated with Replac after the same string, the generation process with Newchar instead of Oldchar, although the value is replaced, the original string variable does not actually change, so it is called immutability
1.4 Briefly describe the relationship between string and character array, use character array to handle string, why do you need string?
Strin is stored in a character array, his storage size is unchanged, if the length of the input string, it will be an error, using string type, automatically identify the size of the string to change the storage space of the array, to prevent wasted space
2.1 In conjunction with PTA-2 (StringBuilder), why should I use StringBuilder instead of string when I frequently modify strings?
String changes the string every time it is new, and then delete the old string will be very inefficient, if the direct connection using StringBuilder modified string, is directly modify the original string, which improves efficiency
2.2 Read the JDK documentation, append(char[] str) What is the method function for querying StringBuilder? What is the internal use of StringBuilder to store characters? How do I implement an operation to add characters when I call Stringbuide's append (char[] str) method?
To add characters to the string is the main function of append (char[] str), StringBuilder is a string array to hold, the character array parameters are appended sequentially, the contents of the sequence, and then the length of this sequence increases the length of the parameter
3. String and String pool3.1 Try to use 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);
2 created two objects. Str1= "HI" begins by creating a Hi string object, and then putting it into the string pool, when defining str2, the JVM detects the string constant pool, and if it finds the same content directly, it does not have to be redefined. when using new to construct a string object, a new string object is created without looking at the reference to the object with the same content in the string constant pool
3.2 Focus: For basic types we can use = = to compare two values for equality, for reference types (such as String, Integer, array, etc.) why can't I use = = comparison? How do you compare their values for equality?
Use "= =" to compare whether the object is the same, and equals () to compare the actual contents of the objects. Because of the immutable nature of string,"= =" has no way of judging its substance.
4.Wrapper (Packaging Class)4.1 Integer i = 100; //100 is a basic type, I is a reference type, why can I be assigned to 100? Integer x = 100; int y = x+1;x++;What is included in this sequence of commands?
Because only the object of the automatic sealing and unpacking, the call will be automatically removed when the box, including automatic sealing, automatic unpacking, and then sealed box
4.2 Why does Java have a basic data type and need its wrapper class? What are the benefits of packing class?
Java is an object-oriented language, but the basic data type is not object-oriented, processing is cumbersome, in order to improve the efficiency of the packaging class can be easily implemented between the basic data types of conversion
5.1 Pair Programming Practice: the use of pairing programming to complete this week's programming problem, that is, two people at the same time to work together to complete the experimental topic (can be more than 1 questions, but preferably two people have not done the topic). Recommended implementation steps: 1. Two people sit in front of the same computer screen to question, discuss, decide who should write first. 2.1 People make 5 minutes (to discuss how many minutes themselves), while another person observes each other's programming or check related information. 3. After 5 minutes, after a brief discussion, for another person to continue the compilation (please be sure to change, if the other person can not accept should be the first person to explain the approximate idea to facilitate their acceptance). and complete the following assignments: A. Describe the pair-mate name, pairing process, and provide a pair of photos that the non-pendulum two people are discussing, refining, and programming. B. Can pair programming really bring 1+1>2 effect? Through this pair programming, please talk about your feelings and experience (such as whether it is conducive to the improvement of their own programming level, is conducive to the development of programming ideas).
Because it is a person in the book tube to check the information book out, so no one to find a team, did not complete this
5.2 PTA-1 Comprehensive Quiz
Use the Array.Sort () function to sort and use the switch statement to invoke the function
5.3 PTA-3 ID card sort. and answer: Using the method to sort the date of birth can be sorted in sort2 ascending order, if it is necessary to sort it in descending order, or according to the month of birth in the order, how to solve it?
First compare the identity of the same part of the character, after comparing, the complete character with for loop output.
5.4 PTA-4 Dynamic Array
This problem is mainly used by ArrayList, in order to avoid the output of the time each line has null, so the loop to open a few lines from the first few spaces to build
5.5 (Focus: Quiz topic) PTA-8 ArrayList get started. and answer: Why do I have an array to use ArrayList?
ArrayList storage space is automatically changed, but the array will not automatically change, in the case can not determine the length of the array, with ArrayList to solve space-saving and more convenient
6. Choose: How much money should be in the bus card? Please analyze the reason
Video Address: http://v.ifeng.com/news/society/201303/bec03216-938b-4618-8e65-64f4e42f5803.shtml
Bus card balance is-0.2 yuan
Perhaps the unsigned number is defined on the machine.
3. Code cloud and PTA3.1. Codes Cloud Code submission record
- In the Code cloud Project, select statistics-commits history-set time period, and then search for and
3.2 Question Set "Java Basic Syntax" PTA Submission List3.3 Use the teacher-issued jar program to count the weekly code volumeNote: Please use the updated version 1.0 of the elder sister, please remove the previous information.txt before using the new version
| Week Time |
Number of rows |
number of new rows |
Number of files |
number of new files |
| 2 |
330 |
330 |
5 |
5 |