Ukraine flag Armor Games stands with Ukraine Ukraine flag
If you’d like to help, please consider giving to Ukraine Crisis Fund

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

1 5056
1,318 posts

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 76-75 of 1

We may use cookies to help customize your experience, including performing analytics and serving ads.
Learn More