I have edited the NullPointerException
present in MainActivity
and have exported (cut, copy and paste)them into another class. But my Logcat shows an error in MainActivity
.
After modifying for `NullPointerException this is my code:
if(value!=null && value.length()>0){
try{
length = Integer.parseInt(value);
}
catch (NullPointerException e){
length=0;
}
}
My logcat shows:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable
android.widget.EditText.getText()' on a null object reference
at com.example.caddrawingtool.MainActivity.drawline(MainActivity.java:114)
at com.example.caddrawingtool.MainActivity.onOptionsItemSelected(MainActivity.java:57)
at android.app.Activity.onMenuItemSelected(Activity.java:4137)
at androidx.fragment.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:384)
at androidx.appcompat.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:228)
androidx.appcompat.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:109)
when my MainActivity
has only 109 lines. I am confused.