No.20169204 Learning Summary, Second Week
Summary of Teaching Content
- Core Classes
This chapter, we will introduce some important Core Classes to you. If you are a formal Java programmer, you should use the class:java.lang.String. It's very useful. String objects are constant. Once they are created, their values cannot be changed. Because of this, String instances are said to be immutable. And, because they are immutable, they can be safely shared.
You can construct a String object in two ways:
String s = "hello"; or you can
String m = new string("hello");
However, they works differently. Etc:
Here, the first,(s1 == s2) evaluates to true because s1 and s2 reference the same instance. On the other hand, in the following code (s1 == s2) evaluates to false because s1 and s2 reference different instances.
If you use the new keyword, the JVM will always create a new instance of String. With a string literal, you get an identical String object, but the object is not always new. It may come from a pool if the string “Java is cool” has been created before. So, if you need to construct a string object, please using the first ways to achieve it.
Comparing two String objects using the == operator is of little use because you are
comparing the addresses referenced by two variables. Most of the time, when comparing two String objects, you want to know whether the values of the two objects are the same. In this case, you need to use the String class’s equals method.
This time will be return to true. But I will warn you to keep the string with no null when you using the equals(), otherwise the system will be die. Error Handling
Error handling is an important feature in any programming language. A good error handling mechanism makes it easier for programmers to write robust applications and to prevent bugs from creeping in. There are two types of errors, compile error and runtime error. Compile errors or
compilation errors are due to errors in the source code. Compile errors are caught by the compiler at compile time. Runtime errors, on the other hand, can only be caught when the program is running.Working with Numbers
Conversion from a primitive type to a wrapper object is called boxing and from a wrapper object to a primitive is called unboxing.In Java you use primitives and wrapper classes to model numbers. Conversion between a primitive and a wrapper class and the other way around happen automatically. There are three types of operations that you frequently perform when dealing with number and dates: parsing, formatting and manipulation.
In this session, I want to tell you, using the random number generator carefully, especially to be a researcher in cryptography.
This does generate random numbers, but its randomness cannot be used in cryptographic schemes!
Problems and Solutions in Teaching Materials
Can anyone tell me why that might be the case?
Problems and Solutions in Code Debugging
- building error
In the import package, you need to end with a semicolon, forgotten here, the Java language in general grammar, is to end a semicolon, develop good programming habits is very important. This allows us to write large programs in the current half times. But after the run is still wrong:
Error: String write to be Stirng, how foolish the error occur to me.
Code hosting
- Code Submission Process Screenshot:
- The Number of Code Screenshot:
Sumary of the test last week
In last week's class, I have a small test to be caught off guard. It is a hard time for me, there are so many mistake which I made, and remind me to study hard in this week. Recall the mistakes before, mostly focused on the basic concept of the textbook and the related tutorials not proficient,as to my answer the question that what's the three most popular IDE environment was wrong!
So, this week, I have paid my attention on the textbook, more focus on some basic knowledge, rather than eager to programming. Carefully read the tutorial, the environment is configured accurately, standardized format for the follow-up study to lay a good foundation for the environment.
Feeling
Two weeks later, the learning method is not very skilled, but I am determined according to this method, continue to study, will have unexpected results. In fact,I learned the basic knowledge of Java was so few in past two weeks, far less than to learn programming much past time. This is due to a lack of understanding of the nature of the compiler. After two weeks of exploration and learning, I gradually understand the operation of the Ubuntu skills, but also enjoy the programming to bring a happy mood. I think I'm more interested in programming.
Finally, thanks to my classmates and teachers help in everything! Thank you!
Learning progress bar
| | Code Line | Bolg | time(hour) | growth |
| --------------- :| : ----------------- :|:----------------- :|: ----------------- :|: ---- :|
| Target | 5000 | 15 | 100 | |
| First week | 200/200 | 1/1 | 3/4 | |
| Second week | 300/500 | 1/1 | 3/4 | |
| Three week | 660/500 | 1/1 | 3/4 | |
Reference
[Java for Android 2nd Edition]
[Java Study notes(8th Edition)Learning guidance]