Life is just composed of a series of birth, age, illness and death. Unfortunately, I am going through a process of illness. I have a cold. Although it is not serious, I am dizzy, with runny nose and tears.
She held a box of cold medicine in her hand and handed it to me. "Eat a bag of cold granules quickly." I was a little stunned and flattered, because it was the first time a girl bought me medicine. I was almost moved to cry, "so good to me?" I can't help asking. She said, "of course, I've got a cold, so I can teach me to write programs!"
I took the medicine box, took out a bag from it, took boiling water, mixed it, and took a sip.
"I'm not busy these days. I want to learn more from you. I didn't expect you to catch a cold." She went on.
"I'm human, too. Isn't it normal to catch a cold?" I said, "but speaking of this" unexpected ", do you know how to deal with unexpected errors in java?"
"I don't know."
"Ha ha, I knew you didn't know." I don't know whether it's because I'm interested or cold medicine works. I suddenly feel refreshed.
"I'll write you an example and you'll understand." I went to get the laptop in front of her.
However, she pushed my hand away and said, "if you are ill, have a good rest and study. It doesn't matter whether you are early or late."
The concern in her eyes surprised and moved me. For a moment, tears and snot came out again.
I had to reach out to the tissue box, take out the tissue, wipe my tears and nose, and say, "it's all right. It's my pleasure to teach you a lesson. A happy mood can make me better faster."
"Really?" She had put away her concern and replaced it with a naughty and joking look. She obviously felt that what I said was just a joke, although it was not a joke to me.
"Yes." I smiled and said, I wanted to look at what she said with very sincere eyes, but I never had that courage.
"All right." She said briskly. Finally, she added with concern, "if you can't, don't force it."
So I took the laptop and wrote the following code:
package com.lj.ex; public class Application { public static void main(String[] args) { System.out.println(division(12,3)); System.out.println(division(12,0)); System.out.println(division(12,3)); } static int division(int a,int b){ return a/b; } }
Operation results:
4 Exception in thread "main" java.lang.ArithmeticException: / by zero at com.lj.ex.Application.division(Application.java:15) at com.lj.ex.Application.main(Application.java:7) Process finished with exit code 1
"Ah, wrong report!" She exclaimed and looked at me suspiciously.
"Yes, it's right to report an error." I said calmly.
"Why is it right to report an error?"
"Because the divisor cannot be zero."
"Yes, don't pass 0 to the second parameter of the function."
"Sometimes, this parameter is generated and passed in during operation, and we are not sure whether it is passed to zero?"
"Is that possible?"
"It's very possible. For example, there are 10 apples to be divided equally among the people in the room, but the people in the room come and go, there may be 0 people."
"You're stupid. Just write an if judgment."
When she said this, I was speechless.
"Well, it seems so." After holding for a long time, I have to admit that she is right.
"Are you confused by a cold?" She looked at me and said seriously, then touched my forehead, "it's really hot. You'd better have a good rest."
"I'm fine. I was taken by you." I calmed down. I wanted to tell her about exception handling, not about how to divide by zero.
"Of course, you're right. Just use if to judge, but if you didn't write the division method, you don't know if it used 'if' to judge whether the divisor is 0. What should you do? So the best way is to catch exceptions with the try... Catch keyword, and then handle them, like this." I changed the code:
package com.lj.ex; public class Application { public static void main(String[] args) { try { System.out.println(division(12, 3)); System.out.println(division(12, 0)); System.out.println(division(12, 3)); }catch (Exception ex){ System.out.println("An exception occurred in the program. The exception information is as follows:"); ex.printStackTrace(); } } static int division(int a,int b){ return a/b; } }
Operation results:
4 An exception occurred in the program. The exception information is as follows: java.lang.ArithmeticException: / by zero at com.lj.ex.Application.division(Application.java:15) at com.lj.ex.Application.main(Application.java:7) Process finished with exit code 0
"See? If an exception occurs in the program segment wrapped by the try keyword, this exception will be matched with the exception type declared in catch. If it matches, it will jump to the program segment behind catch." I explained to her.
"Wait, I have two questions:
1. What if it doesn't match?
2. Add this try... catch. It doesn't have any effect. It doesn't do anything except print one more line of words. The later 12 divided by 3 still doesn't work. "
"If there is no match, of course, an error is reported, and then the program exits abnormally. This is the role of try... Catch. With it, in case of an exception, the program will jump to the matching catch and execute later, rather than directly exit, that is, it will not exit abnormally. You can see that the exit code of the program is different. The code for abnormal exit is 1 and the normal exit code is 0." Then I pointed out to her the line in the output interface that outputs the exit code: "Process finished with exit code 0".
"As for the second question, it's not difficult to explain. The reason is that an exception is thrown in the sentence 'System.out.println(division(12, 0));'. After the catch is caught, it will be executed from the catch. Naturally, the following 12 divided by 3 will not be executed." Seeing that she didn't seem to respond, I continued, "I don't believe it. If you change the code like this, 12 divided by 3 will execute.".
Code modified again:
package com.lj.ex; public class Application { public static void main(String[] args) { try { System.out.println(division(12, 3)); System.out.println(division(12, 0)); }catch (Exception ex){ System.out.println("An exception occurred in the program. The exception information is as follows:"); ex.printStackTrace(); } System.out.println(division(12, 3)); } static int division(int a,int b){ return a/b; } }
Operation results:
4 An exception occurred in the program. The exception information is as follows: 4 java.lang.ArithmeticException: / by zero at com.lj.ex.Application.division(Application.java:15) at com.lj.ex.Application.main(Application.java:7) Process finished with exit code 0
"Oh, I see. Exception handling allows the program to continue normal when encountering an exception, rather than exiting directly. Is that right?" She looked at the results of the program, nodded and said.
"That's right." I'm sure I will.
"Well, I think I've learned this Exception handling." She said excitedly and suddenly wondered, "However, I found a problem. Didn't you say that the code behind catch will be executed only when the Exception in the program matches the Exception type declared in catch? But the above example obviously doesn't match. The Exception thrown by the program is: ArithmeticException, but what you catch with catch is: Exception."
"Ha ha, you observed it very carefully." I smiled and said, "that's because I'm lazy. All Exception classes inherit from Exception directly or indirectly, that is, all types of exceptions can be regarded as exceptions. Naturally, exceptions can be used to catch exceptions of ArithmeticException type. More generally, parent Exception classes can be used to catch exceptions of child Exception classes."
"Oh, I see. In that case, can I catch it with an Exception no matter what Exception it is?" She said.
"Of course, it's lazy and very safe." I agreed with her, and then said, "but many times, you need to deal with different exceptions differently. At this time, you can't just use an Exception."
"Yes, what should I do?"
"It's very simple. Just use a few more catches to catch and handle different exceptions, just like this." I changed the code:
package com.lj.ex; public class Application { public static void main(String[] args) { try { System.out.println(division(12, 3)); System.out.println(division(12, 0)); }catch (ArithmeticException ex){ System.out.println("Note: divisor cannot be 0!"); }catch (NumberFormatException ex){ System.out.println("Note: the number format is incorrect!"); }catch (Exception ex){ System.out.println("An exception occurred in the program. The exception information is as follows:"); ex.printStackTrace(); } System.out.println(division(12, 3)); } static int division(int a,int b){ return a/b; } }
"Oh, I see." It's very simple, so she said with a sudden realization.
"However, there are still several things to pay attention to here. One is that the same exception type cannot appear in the catch list. The second is that the parent exception type must be after the child exception type. It is wrong to write like this."
Incorrect writing:
package com.lj.ex; public class Application { public static void main(String[] args) { try { System.out.println(division(12, 3)); System.out.println(division(12, 0)); }catch (ArithmeticException ex){ System.out.println("Note: divisor cannot be 0!"); }catch (Exception ex){ System.out.println("An exception occurred in the program. The exception information is as follows:"); ex.printStackTrace(); }catch (NumberFormatException ex){ System.out.println("Note: the number format is incorrect!"); }catch (NumberFormatException ex){ System.out.println("Note: the number format is incorrect!"); } System.out.println(division(12, 3)); } static int division(int a,int b){ return a/b; } }
"Because the exception capture processing is also executed from front to back, it is meaningless to capture all the exceptions that have been captured before. Therefore, it can't be written like this. The java compiler won't compile such code, and will report an error to tell you that the exception has been captured."
"OK, I see, but then again, I won't be so stupid to write code. Do I have to catch the exceptions I catch?"
"Generally speaking, I won't do that. I just want to remind you."
“ok. ” She made an OK gesture with her hand and said, "that's the end of the knowledge point of exception handling."
"Well, if you are the person who wrote the division method, your division is strange. Except that the divisor can't be 0, it can't be 3. How do you implement such a division method?" Instead of answering her question, I asked her a question.
"Well, let me see." She tilted her head and said excitedly, "this is very simple. Look at me."
With that, her ten fingers danced on the computer keyboard.
The code she implements:
package com.lj.ex; public class Application1 { public static void main(String[] args) { Result r=division(1,0); if(r.code!=0){//There are errors System.out.println(r.msg); }else { System.out.println(r.result); } r=division(1,3); if(r.code!=0){//There are errors System.out.println(r.msg); }else { System.out.println(r.result); } r=division(1,4); if(r.code!=0){//There are errors System.out.println(r.msg); }else { System.out.println(r.result); } } static Result division(float a,float b){ if(b==0){ return new Result(0,-1,"Divisor cannot be 0"); } if(b==3){ return new Result(0,-2,"Divisor cannot be 3"); } float f=a/b; return new Result(f,0,"no problem"); } } class Result{ float result; int code; String msg; public Result(final float result, final int code, final String msg) { this.result = result; this.code = code; this.msg = msg; } }
Operation results:
Divisor cannot be 0 Divisor cannot be 3 0.25 Process finished with exit code 0
"How's it going? Is it OK?" Looking at the running results, she said proudly.
"It's very good. I've even used the classes and objects I've learned before." I smiled and said, "but it's still a little troublesome. In fact, it can be realized very simply."
"Really?" She didn't believe it. "Then write it and have a look."
"Then look." Then my fingers danced on the computer keyboard.
Code I implemented:
package com.lj.ex; public class Application2 { public static void main(String[] args) { try { System.out.println(division(12, 0)); }catch (Exception ex){ System.out.println(ex.getMessage()); } try { System.out.println(division(12, 3)); }catch (Exception ex){ System.out.println(ex.getMessage()); } try { System.out.println(division(12, 4)); }catch (Exception ex){ System.out.println(ex.getMessage()); } } static int division(int a,int b) throws Exception { if(b==3){ throw new Exception("Divisor cannot be 3"); } return a/b; } }
Operation results:
/ by zero Divisor cannot be 3 3 Process finished with exit code 0
"Is it much simpler than what you wrote?" I said.
"Can you still do this?" She obviously said "throw new exception" This line of code.
"Of course, not only can the system throw exceptions, but also the code you write can throw exceptions." I explained, "if a method you write wants to throw an Exception, use the 'throws' keyword behind the method signature to list the types of exceptions you want to throw. I'm naturally lazy here. I directly list the class Exception. Naturally, any type of Exception can be thrown in this method."
"Well, I see." She said, "if there are multiple types of exceptions to throw, are these exception classes listed by throws separated by commas?"
"Yes, you are too clever. I was about to say it. You have guessed it."
"That's right. I'm talented and intelligent."
"Yes, yes, but there is another point. This Exception class can also be customized, as long as it directly or indirectly inherits from the Exception class. For example, we can write the program just now."
My modified code:
package com.lj.ex; public class Application2 { public static void main(String[] args) { try { System.out.println(division(12, 0)); }catch (Exception ex){ System.out.println(ex.getMessage()); } try { System.out.println(division(12, 3)); }catch (Exception ex){ System.out.println(ex.getMessage()); } try { System.out.println(division(12, 4)); }catch (Exception ex){ System.out.println(ex.getMessage()); } } static int division(int a,int b) throws Exception,Num3Exception,Num3Exception { if(b==3){ throw new Num3Exception("Divisor cannot be 3"); } return a/b; } } class Num3Exception extends Exception{ public Num3Exception(final String message) { super(message); } }
Operation results:
/ by zero Divisor cannot be 3 3 Process finished with exit code 0
In order to show the situation that multiple exception types are to be thrown, I deliberately listed several more exception types and repeated exception types after the throws of the division method, because repeated exception types will not make mistakes, although in fact we won't do such stupid things.
"Oh, I see." After reading the code I changed again, she nodded.
Finally, she asked, "is there anything else about exception handling?"
"No, that's all." I answered.
"Ha ha, I'm so happy. I've learned another knowledge point." She was elated at my answer.
Then, very suddenly, she looked at me seriously and said, "have you recovered from your cold?"
At this time, I found that my head was not dizzy and my nose was not runny. It seems that the cold granule she gave me has a good effect, and my cold is basically good.
So I answered her, "yes, I think so."
She reached out and touched my forehead, then nodded and said, "well, it's not hot. It seems that it's really good."
I didn't know what to say. She smiled cunningly and continued, "since you've recovered from your cold, it's still early now. Why don't you teach me more?"
Although she said a question, I knew she was actually an affirmative sentence, so I nodded and said, "OK, let's take a look at some class libraries commonly used in java."
"Class library?" She asked.
"It is a collection of many classes and interfaces organized into a package structure provided by the commonly used java language, which can also be called java API." I explained.
"Oh." She said oh and looked at me, which means "you go on".
I have to continue to explain: "in fact, it is mainly some tool classes and methods, such as the most commonly used string operation classes."
At this point, I looked at her and saw that she didn't respond, so I had to start typing the code.
Because I know that I can't understand it. Write an example code and she will understand it at a glance.
Sample code used by StringBuffer:
package com.lj.ex; public class Application3 { public static void main(String args[]){ //String connect operation (append) StringBuffer buf = new StringBuffer() ; // Declaring a StringBuffer object buf.append("Hello ") ; // Add content to StringBuffer buf.append("World").append("!!!") ; // The append() method can be called consecutively buf.append("\n") ; // Add an escape character buf.append("number = ").append(1).append("\n") ; // Add number buf.append("character = ").append('C').append("\n"); // Add character buf.append("Boolean = ").append(true) ; // Add Boolean System.out.println(buf) ; // Directly output the object and call toString() System.out.println(""); //Add content to string (insert) buf = new StringBuffer() ; // Declaring a StringBuffer object buf.append("World!!") ; // Add content buf.insert(0,"Hello ") ; // Add content before the first content System.out.println(buf) ; System.out.println(""); //String reverse buf = new StringBuffer() ; // Declaring a StringBuffer object buf.append("Hello World!!") ; // Add content String str = buf.reverse().toString() ; // Invert the content to a String type System.out.println(str) ; // Output content System.out.println(""); //Replace the specified content of the string (replace) buf = new StringBuffer() ; // Declaring a StringBuffer object buf.append("Hello ").append("World!!") ; // Add content to StringBuffer buf.replace(6,11,"even my yeah") ; // Replace the contents of world System.out.println("Results after content replacement:" + buf) ; // Output content System.out.println(""); //String interception (substring,delete) buf = new StringBuffer() ; // Declaring a StringBuffer object buf.append("Hello ").append("World!!") ; // Add content to StringBuffer buf.replace(6,11,"even my yeah") ; // Replace the contents of world str = buf.substring(6,11) ; // Intercept the content of the specified range // String str = buf.delete(6,11).toString() ;// Delete content in the specified range System.out.println(buf); System.out.println("Results after content replacement:" + str) ; // Output content System.out.println(""); //Find specified content (indexOf) buf = new StringBuffer() ; // Declaring a StringBuffer object buf.append("Hello ").append("World!!") ; // Add content to StringBuffer if(buf.indexOf("Hello")==-1){ System.out.println("The specified content was not found") ; }else{ // Not - 1 means that the content is found System.out.println("You can find the specified content") ; } } }
I wrote a little too much at once, and she looked at it carefully. Before I could speak, she spoke first: "ha ha, it's really convenient to use this StringBuffer to operate strings. Is this StringBuffer the class of the class library? “
”Yes, Java provides many convenient class libraries for developers. For example, the operation string includes StringBuilder in addition to the StringBuffer class. "
"Oh, is its usage similar to StringBuffer?"
"Almost. There are many examples on the Internet, and the current IDE integrated development environment also has code prompts.", I didn't want to write almost the same code again, so I said.
"Well, just check it when you want to use it. What else is there besides the class library classes that operate strings?" She was not in a hurry to check the usage of StringBuilder, but asked for other contents of the class library.
This is also a way to learn programming. It is certainly impossible to remember these detailed things one by one. We just need to know that there is it. When using it, just check it.
It seems that she has mastered the essence of learning programming language. In this case, I don't have to tell her the usage of no class library classes. I just need to tell her what each class is used for.
So there are some dialogues like reciting the text:“
1. Runtime class, which is an operation class related to the runtime environment in Java. You can use it to obtain the memory information of the system. You can also call its methods to collect garbage and free memory space.
2. System class, which is a collection of system related properties and methods, such as system out. Println is the method of using the static attribute out of the system class.
3. Date operation classes mainly include date, calendar, dateformat and SimpleDateFormat. Date is an abstraction of time. Calendar can add, subtract and compare time. Dateformat and SimpleDateFormat are used to format time.
4. Math class, which contains some mathematical calculation methods, such as finding the absolute value of a number, finding the square of a number, etc.
5. Random class, which is used to find random numbers.
6. NumberFormat class, which is used to format numeric values.
7. BigInteger class, which can be used to handle large integers.
8. Bigdecimal class, which is a processing class for size numbers.
9. Arrays class, a class that operates on arrays, such as array sorting.
10. Timer and TimerTask are scheduled. Timer is responsible for scheduling. TimerTask is an abstract class representing a task.
"
"What I listed are some commonly used ones. If you need to use them in the future, just go to Baidu. There are many examples. You can see at a glance." Finally, I said to her.
"OK." She said happily, as if she had harvested a lot of money and was putting it in her pocket.
Looking at her happy appearance, I seemed quite satisfied and smiled unconsciously.
"What are you laughing at?" She asked suddenly.
Suddenly asked by her, I felt a little embarrassed and said, "I didn't laugh. So what? Let's continue to look at the collection framework. “
I wanted to change the subject quickly, but I didn't expect her to be reluctant.
"What are you laughing at?" She asked again.
"I'm not laughing." I said, "you look like you've found money. I'm happy for you."
"Ha ha, I'm very happy. Learning so much knowledge is happier than picking up money."
"Just be happy. Let's go on."
"OK."
"Remember the sorting program we wrote before?" I asked her.
"Of course." She said, then touched her hair and said, "the program is a little complicated. It takes a little time to write it."
"Ha ha, it's true. But these java class libraries have helped you do it. In fact, you don't have to sort by yourself."
"How?"
"Write you an example."
So I started writing code again:
package com.lj; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Application5 { public static void main(String[] args) { List l = new ArrayList(); l.add(1); l.add(3); l.add(2); l.add(5); l.add(4); Collections.sort(l); System.out.println("l->" + l); List<T1> l1 = new ArrayList(); l1.add(new T1("Xiao Ming", 2)); l1.add(new T1("floret", 1)); l1.add(new T1("Xiao Hong", 3)); Collections.sort(l1, new Comparator<T1>() { public int compare(T1 o1, T1 o2) { return o1.age - o2.age; } }); System.out.println("l1->"+l1); } } class T1 { String name; int age; T1(String name, int age) { this.name = name; this.age = age; } @Override public String toString() { return "T1{" + "name='" + name + '\'' + ", age=" + age + '}'; } }
Operation results:
C:\Java\jdk1.8.0_131\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\lib\idea_rt.jar=61898:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Java\jdk1.8.0_131\jre\lib\deploy.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\access-bridge-64.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\cldrdata.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\dnsns.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\jaccess.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\jfxrt.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\localedata.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\nashorn.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunec.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunjce_provider.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunmscapi.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunpkcs11.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\zipfs.jar;C:\Java\jdk1.8.0_131\jre\lib\javaws.jar;C:\Java\jdk1.8.0_131\jre\lib\jce.jar;C:\Java\jdk1.8.0_131\jre\lib\jfr.jar;C:\Java\jdk1.8.0_131\jre\lib\jfxswt.jar;C:\Java\jdk1.8.0_131\jre\lib\jsse.jar;C:\Java\jdk1.8.0_131\jre\lib\management-agent.jar;C:\Java\jdk1.8.0_131\jre\lib\plugin.jar;C:\Java\jdk1.8.0_131\jre\lib\resources.jar;C:\Java\jdk1.8.0_131\jre\lib\rt.jar;D:\myprojects\java_study\exception\target\classes com.lj.Application5 l->[1, 2, 3, 4, 5] l1->[T1{name='floret', age=1}, T1{name='Xiao Ming', age=2}, T1{name='Xiao Hong', age=3}] Process finished with exit code 0
"Look, so you can sort with the list of the collection framework. It arranges itself without you." After the code is written and the results are run, I say, "and the numbers to be sorted can be added dynamically and the objects can be sorted"
"This is good. It doesn't cost hair. Ha ha."
"Well, this collection framework is a group of related classes that process a batch of data. Besides ArrayList, list also has LinkedList, etc. Besides list, it also has set, which can remove duplication; and map, which stores data in the form of key value pairs."
"I'd better write an example for you." Finally, I said.
code:
package com.lj; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class Application6 { public static void main(String[] args) { Set set= new HashSet(); set.add(1); set.add(3); set.add(1); set.add(2); set.add(2); System.out.println("set->"+set); Map<String,Integer> map=new HashMap<String, Integer>(); map.put("floret",10); map.put("floret",13); map.put("Xiao Hong",12); System.out.println("map->"+map); } }
Operation results:
C:\Java\jdk1.8.0_131\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\lib\idea_rt.jar=58176:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Java\jdk1.8.0_131\jre\lib\deploy.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\access-bridge-64.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\cldrdata.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\dnsns.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\jaccess.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\jfxrt.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\localedata.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\nashorn.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunec.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunjce_provider.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunmscapi.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\sunpkcs11.jar;C:\Java\jdk1.8.0_131\jre\lib\ext\zipfs.jar;C:\Java\jdk1.8.0_131\jre\lib\javaws.jar;C:\Java\jdk1.8.0_131\jre\lib\jce.jar;C:\Java\jdk1.8.0_131\jre\lib\jfr.jar;C:\Java\jdk1.8.0_131\jre\lib\jfxswt.jar;C:\Java\jdk1.8.0_131\jre\lib\jsse.jar;C:\Java\jdk1.8.0_131\jre\lib\management-agent.jar;C:\Java\jdk1.8.0_131\jre\lib\plugin.jar;C:\Java\jdk1.8.0_131\jre\lib\resources.jar;C:\Java\jdk1.8.0_131\jre\lib\rt.jar;D:\myprojects\java_study\exception\target\classes com.lj.Application6 set->[1, 2, 3] map->{Xiao Hong=12, floret=13} Process finished with exit code 0
"In fact, learning these collection classes is basically enough." After running the code, I said.
"Uh huh." she nodded as she looked at the code.
After reading it, she said happily, "well, I learned it, ha ha. “
I suddenly felt a little dizzy. It seems that I haven't recovered from my cold, so I said, "no, I'm a little dizzy. Let's talk so much today."
She showed a little nervousness and asked with concern, "what's the matter? The cold hasn't recovered yet."
Before I could speak, she said, "wait, I'll make you a bag of cold granules."
Then he went to exchange cold granules.
After drinking Ganmao granule, the symptoms of dizziness were relieved. Looking at the time, it was not early, so I said, "it's late, it's time to go home."
"Well, it's getting late. Let's go."
So he cleaned up and left the office.
ps:
Several key points in this section: exception handling, common class libraries, and collection framework