Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

y to implement serializable in getter & setter ?

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why do we implement serializable in getter and setter ???
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The data you are going to set or get using getter or setter method some times may need to pass through network from one remote to another remote system.Serializable is property that allows you to write the data or the object state into an output stream and fetch it back from there...
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why do we implement serializable in getter and setter ???


Can you please explain your question more clearly?

Getters and setters are methods. You cannot implement interface Serializable in a method. Is your question about what Serializable means?

Or did you mean to ask why in a Java Bean (which is a class that has getter and setter methods) you should implement Serializable? If you meant that, that's because it's one of the criteria which makes a class a Java Bean. Wikipedia says:

"In order to function as a JavaBean class, an object class must obey certain conventions about method naming, construction, and behavior. These conventions make it possible to have tools that can use, reuse, replace, and connect JavaBeans.

The required conventions are:

* The class should be serializable (able to persistently save and restore its state)
* It should have a no-argument constructor
* Its properties should be accessed using get, set and other methods following a standard naming convention
* It should contain any required event-handling methods"
 
Sheriff
Posts: 67583
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"y" is not a word. Please use real words such as "why" when posting. Please read this for more information.
[ February 22, 2007: Message edited by: Ernest Friedman-Hill ]
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say that the Wikipedia article is wrong at least about the getXXX() setXXX() naming convention being required.
 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I would say that the Wikipedia article is wrong at least about the getXXX() setXXX() naming convention being required.


How so? The rules a bean must follow are mentioned here, and nothing about that naming convention sounds optional to me.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe it is because for booleans you can use the isXXX method.
 
straws are for suckers. tiny ads are for attractive people.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic