java - Making custom object convertible -
in java possible me design own class convertible(or castable?) primitive type? example, if have:
class intstring{ private int intval; private string strval; public intstring(int intval, string strval){ this.intval = intval; this.strval = strval; } } static void main(string[] args){ intstring intstr = new intstring(1,"yes"); }
is possible have like:
int inttstval = intstr;
or even
int inttstval = (int)intstr;
?
and can make class work string in same fashion?
thanks
not implicitly can implements same/similar methods wrappers use.
int inttstval = intstr.intvalue(); string text = intstr.stringvalue();
Comments
Post a Comment