Hello, I seem to have encountered a problem with this code.
try
{
String changeC1 = JOptionPane.showInputDialog (null, "Change the dimensions of silo 1? (y/n)");
}
catch (NullPointerException e)
{
String changeC1 = "n"; // probably also be a good idea to log the fact an exception occured.
}
try
{
String changeC2 = JOptionPane.showInputDialog (null, "Change the dimensions of silo 2? (y/n)");
}
catch (NullPointerException e)
{
String changeC2 = "n";
}
if (changeC1.equalsIgnoreCase("y") && changeC2.equalsIgnoreCase("y"))
{
changeDimensionsOne(iRadius, iHeight, c1, MAX);
changeDimensionsTwo(iRadius, iHeight, c2, MAX);
displayDimensions(c1, c2);
}
else if (changeC1.equalsIgnoreCase("y"))
{
changeDimensionsOne(iRadius, iHeight, c1, MAX);
displayDimensions(c1, c2);
}
else if (changeC2.equalsIgnoreCase("y"))
{
changeDimensionsTwo(iRadius, iHeight, c2, MAX);
displayDimensions(c1,c2);
}
}
I am assuming this is because the String object is inside a catch block. How do I make it so that my if statement can recognise it?
Thanks for any help! :)