Operator overloading in Java (Integer wrapper class)? -


this question has answer here:

i came across example in ocjp book. says

integer y=new integer("20"); y++;   (un-wraps it) system.out.println(y); 

now, print 21. hence, makes me think, how did compiler know @ y++ should unwrap int , increment it? integer normal class(may wrapper class??), operator overloading inbuilt inside?

is there way can own custom class if possible?

java uses feature called autoboxing , unboxing unwrap integer , increment it. cannot implement feature in own user-defined classes. available wrapper classes java primitive types.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -