PackagePrimitivetypedefaultvalue; Public classListdefaultvalue { Public Static voidMain (string[] args) {PrimitiveType pt=NewPrimitiveType (); System.out.println (Pt.tostring ()); }}classprimitivetype{@Override PublicString toString () {StringBuilder pt=NewStringBuilder (); Pt.append ("Age (int):"). Append ( This. Getage ()). Append ("\ n"). Append ("Moneyl:"). Append ( This. Getmoneyl ()). Append ("\ n"). Append ("Moneyf:"). Append ( This. GETMONEYF ()). Append ("\ n"). Append ("Moneyd:"). Append ( This. Getmoneyd ()). Append ("\ n"). Append ("Sex (char):"). Append ( This. Getsex ()). Append ("; "). Append ("Length (original):"). Append (String.valueof ( This. getsex ()). Length ()). Append ("; "). Append ("Length (after Trim ()):"). Append (String.valueof ( This. Getsex ()). Trim (). Length ()). Append ("\ n"). Append ("Retire (Boolean):"). Append ( This. Isretire ()). Append ("\ n") ; returnpt.tostring (); } Public intGetage () {returnAge ; } Public voidSetage (intAge ) { This. Age =Age ; } Public LongGetmoneyl () {returnMoneyl; } Public voidSetmoneyl (LongMoneyl) { This. Moneyl =Moneyl; } Public floatGetmoneyf () {returnMoneyf; } Public voidSETMONEYF (floatMoneyf) { This. Moneyf =Moneyf; } Public DoubleGetmoneyd () {returnMoneyd; } Public voidSetmoneyd (DoubleMoneyd) { This. Moneyd =Moneyd; } Public CharGetsex () {returnsex; } Public voidSetsex (Charsex) { This. Sex =sex; } Public BooleanIsretire () {returnretire; } Public voidSetretire (Booleanretire) { This. Retire =retire; } Private intAge ; Private LongMoneyl; Private floatMoneyf; Private DoubleMoneyd; Private Charsex; Private Booleanretire;}
Output:
The initial value of the Java base type as a member variable