Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

is enum type serializable by default?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am creating an enum type (public enum ApplicationEnum) and using it as a class member in a domain object. Is this ApplicationEnum (which is of type enum) is serializable by default or do i have to explicitly declare the enum ApplicationEnum as Serializable.

Lastly, is enum involved in a Serialization mess?

Thanks aton for all your help.

Regards,
Balaji N
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sun's enum tutorial:
All enums implicitly extend java.lang.Enum.



java.lang.Enum Javadoc:
All Implemented Interfaces: Serializable, Comparable<E>




[ August 22, 2008: Message edited by: Jelle Klap ]
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Balaji Natarajan:
I am creating an enum type (public enum ApplicationEnum) and using it as a class member in a domain object. Is this ApplicationEnum (which is of type enum) is serializable by default or do i have to explicitly declare the enum ApplicationEnum as Serializable.



Write a piece of code that creates an instance of your enum and then uses instanceof to check if it implements the Serializable interface.

Edit - or you could look at the documentation

Originally posted by Balaji Natarajan:
Lastly, is enum involved in a Serialization mess?



What do you mean by 'a Serialization mess' ?
[ August 22, 2008: Message edited by: Joanne Neal ]
 
Balaji Natarajan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies.

i meant would enums be involved in Serialization?
Sorry for the language used.

Now i understood that it will be taking part in serialization since it is serializabe.

Thanks for your help.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an easy way to find if a type (e.g. class,enum ) is serializable or not. is to use the serialver command

http://download.oracle.com/javase/1.4.2/docs/tooldocs/solaris/serialver.html

if a type is not serializable, it will print out an error message, otherwise you will get the serialVersionUID.

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic