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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -