As I review, I would like to put some notes here as a reference, and a reminder that I am, actually and necessarily making progress everyday.
- Using Primitive Data Types
- Exploring Syntax and Flow
- Working with Complex Objects
- Exception Handling and Debugging
- Using Data Collections
- Creating Custom Classes
- Working with Inheritence and Polymorphism
- Working with Files
- Preparing an Application for Deployment
Using Primitive Data Types
- If a STRING is not true, then it must be false.
toStringmethod (function, in fact)
Exploring Syntax and Flow
breakis very important in
switchstatement. If you don’t add it at the end of each case, it will keep running until the end of
- The efficiency of loop does not matter so much with the format (for, foreach while and do/while). But it does matter if your compiler is not efficient.
- In JAVA, STRINGS are immutable. Aka, when you pass a string, you are just copying its value to a new place, you CAN NOT change the ORIGINAL value.
- A copy of the entire string is created when passed to a function.
- Some methods of
Stringare very useful. And the more you put them into practice, the better you can remember them. Practice makes perfect.
Working with Complex Objects
- Some useful Classes when deal with date values:
Exception Handling and Debugging
- Compile-time and run-time errors. Q: What are the differences between them?
- ArrayIndexOutOfBoundsException. (Very typical, do you know why?)
try...catch...finally...It is often used in Java, most of the time because you are not sure what will happen in the run time.
Using Data Collections
- Two dimension string.
- Resizable arrays with
- You can manage unordered data with
HashMap. It’s a CLASS.
- Data in Hash Map is not in a particular order. So the only way is to use your key.
- Loop through collections using
Creating Custom Classes
- Encapsulation: Packing of complex functionality to make it easy to use in an application.
- Refactor is really important in all kinds of programming.
- Organizing classes with packages.
settermethods in class fields definition.
- Abstraction is essential for a good program. One “good” example is the Macro or
DEFINEkeyword in C and C++. In this lecture one example is,
public static long final BLACK = 0x00000000.
Working with Inheritence and Polymorphism
- Inheritence and Polymorphism are the TWO major features of Object-Oriented Programming.
- Inheritence: Parent/Child, Base/Derived, Superclass/Subclass. (they have the same meaning!)
extendsis used to create a subclass from superclass.
- The details are hidden within the implementation.
thiskeyword is very useful when you want to change something with super or subclass.
- As an extremely common feature of Object-Oriented Programming, you can easily OVERRIDE the functions (they call methods) from subclass to superclass.
- Casting. One example:
Kalamata olive1 = (Kalamata)olives.get(0). Force the new object olive1 to be Kalamata type. (Read more: why Typed Racket is necessary.)
- Interface. More of less like superclass and subclass relationship. But it’s mostly for functions, I guess. Yeah, it deals with ABSTRACTION. They give you the rough idea of what you should do, then you use the superclass to fulfill the final functions.
- Abstract class and methods.
abstractensures that functions of superclass are implemented. “This method must be implemented!!!”.
Working with Files
- When dealing with files, beware to handle the exceptions.
FileUtilsfrom Apache Commons is helpful.
- Parsing an XML file. Using Java Core library, or you can choose to use those third-party libraries.
Preparing an Application for Deployment
- A JAR file is just a ZIP file. It is used to package your file for deployment.
This part of review is almost finished. Now let’s get down to How to Design Programs, and more importantly, The Structure and Interpretation of Computer Programs, aka, SICP. This course is still being taught in MIT, for first year CS students.