Here is a piece of code from getItem method of FragmentPagerAdapter:
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
switch (position){
case 0:
fragment = new FragmentLight();
break;
case 1:
fragment = new FragmentDark();
break;
}
return fragment;
}
QUESTIONS:
- Why is fragment declared as "Fragment fragment = null;", and what is the meaning of null?
- Why can I not just put here "Fragment fragment;" what is a difference between these two examples?