Operator overloading in Java (Integer wrapper class)? -
this question has answer here:
- is autoboxing possible classes create? 3 answers
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
Post a Comment