Khi truyền dữ liệu bằng socket, em thấy phải convert object sang serializable, vậy khi nào mình nên dùng transient cho hợp lý ạ. Em biết transient giúp trường đó không bị serializable, nhưng mục đích là gì ạ
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Em có thể tham khảo bài viết này. Trong java nó có hỗ trợ serialize đối tượng ra byte array và deserialize từ byte array về đối tượng.
2. Tuy nhiên là có nhiều trường chúng ta không muốn nó serialize một số trường ra byte array, ví dụ:
Vì trường password chứa dữ liệu nhạy cảm. Vậy nên từ khoá
transient
ra đời để làm mục đích này em ạ.