ForumsProgramming Forum[Answered] This Java error blew my mind... maybe u can find its cause?

1 1187
dorukayhan
offline
dorukayhan
1,325 posts
Bard

boolean metricUsage;
public void setMetricUsage(String asdf){
if(!asdf.equals(null) && asdf != null && (asdf.equals("yes") || asdf.equals("Yes") || asdf.equals("yES") || asdf.equals("YES") || asdf.equals("YEs"))){metricUsage = true;}
else if(!(!asdf.equals(null) && asdf != null && (asdf.equals("yes") || asdf.equals("Yes") || asdf.equals("yES") || asdf.equals("YES") || asdf.equals("YEs")))){
javax.swing.JOptionPane.showMessageDialog(null, "If it wasn`t a 'no', I assume it is.");
metricUsage = false;
}
}

i swear i got a nullPointerException at that if-else statement... WHY?

edit: oh i forgot to tell that this method was in a subclass with several other methods that were referenced directly with jOptionPanes. i merged the methods and the jOptionPane commands in a constructor and evrything worked

  • 1 Reply
Showing 46-45 of 1