Doing a little test on Android, writing this code in the backend:

And writing this code in the backend:
NullPointer Exception error is happening.
Can you please explain why, and how to fix?
>Solution :
Your Activity has no view upon object creation. Calling findByViewId before SetContentView will result in this problem.
setContentView(R.layout.activity_main);
//call after there is a view to get from.
test = findViewById(R.id.test);
As a future note please post code as text and not images or links, unless you need to show behavior that can’t be explained.
