What does it mean to add @suppresswarnings ("Serial") to a Java program?

Source: Internet
Author: User
For example, there is a class that implements the Java.io.Serialize interface:
Package com.on.test;

public class Testserial implements Java.io.Serializable {

}
If the code is written just like this, it will give you a yellow warning in eclipse, 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 does not have to)
As long as you add a field like this, the yellow warning disappears, but if you don't want to add the field and don't want to see the yellow warning, it's OK to add a note to the Class (@SuppressWarnings ("Serial").

Package com.on.test;

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

}
So eclipse won't have that yellow warning.

However, we recommend that you give the private static final long serialversionuid = 5952689219411916553L;
When your class is serialized and deserialized, if you do not have this field can be problematic, so try to add this field, do not use @suppresswarnings ("serial") annotation

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.