TracyDai23 / Leetcode

0 stars 1 forks source link

Java Projects Notes #6

Open TracyDai23 opened 4 years ago

TracyDai23 commented 4 years ago

Project_Bank

All public methods have been set as return boolean, so it allows main method to check if not exist or not true. Very good OOP design trick. Example:

public boolean addCustomerTransaction(String customerName, double amount){
        Customer existingCustomer = findCustomer(customerName);
        if(findCustomer(customerName)!= null){
            existingCustomer.addTransaction(amount);
            return true;
        }
        return false;
    }
TracyDai23 commented 4 years ago

DataOutputStream - WriteInt function

?? From Java Udemy video 237 Byte Streams and 238 Reading Binary Data and End of File Exceptions, I am not understand why need to use WriteInt function here. And what it used for.

Serialization: Reasons why need to declare serialVersionUID field:

  1. We explicitly use serialization as we do when we use ObjectInputStream and the ObjectOutputstream classes;
  2. there may be a compatibility issue down the road.
TracyDai23 commented 4 years ago

RandomAccessFile

https://blog.csdn.net/qq_16628781/article/details/70767078