android - Use of nullable in onCreateView and onCreatedView -
i have 2 fragments classes , b , 1 mainactivity class.i looked tutorials , have added recycler view(this not main concern though).following tutorial on both fragment classes have code
@nullable @override public view oncreateview (layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate){ view rootview = inflater.inflate(r.layout.absent, container, false); return rootview; } @override public void onviewcreated(view view, @nullable bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); } so use of @nullablehere?.i have searched many times can't understand it's use , tutorial haven't mentioned @nullabe.can make me understand this? please don't bother in talking recycler view because have added it.
the @nullable annotation indicates variable, parameter, or return value can null ever "nullpointerexception"? that's because value null.
integer x; 'x' null because haven't assigned value there errors using it. if have variable might null in use cases? well, you'd use @nullable annotation meaning it's okay null.
@nullable bundle savedinstancestate bundle in case might have nothing stored in it. it's okay null when method called.
same goes method oncreateview() meaning return can null
Comments
Post a Comment