What does adding @suppresswarnings ("Serial") in Java programs mean?

Source: Internet
Author: User

For example, there is a class that implements the Java.io.Serialize interface:
Package com.onede4.test;

public class Testserial implements Java.io.Serializable {

}
If the code just writes this, putting it in eclipse will give you a yellow warning, why, because you implemented the serializable interface, but did not give
Private static final long serialversionuid = 5952689219411916553L;
A private field like this (this field is required to implement the serializable interface, but not required)
Just add a field like this and the yellow warning disappears, but if you don't want to add this field and don't want to see that yellow warning, no problem, add an annotation to the class (@SuppressWarnings ("Serial"))

Package com.onede4.test;

@SuppressWarnings ("Serial")
public class Testserial implements Java.io.Serializable {

}
So eclipse won't have that yellow warning.

However, we recommend the private static final long serialversionuid = 5952689219411916553L;
When your class is serialized and deserialized, if there is a problem with this field, try adding this field instead of @suppresswarnings ("serial") annotations

What do you mean by adding @suppresswarnings ("serial") to the

Java program?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.