This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Here is part of a sample program I'm trying to compile.
public void setSTATE (String state) throws InvalidStateException { String states[] = {"AL","AL","AZ","AR","CA","CO","CT", "CE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA", "ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH", "NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC", "SD","TN","TX","UT","VT","VA","WA","DC","WV","WI","WY"}; if (state.length() != 2) throw new InvalidStateException(state); for (int i=0; i<states.length;i++) { if (state.equals(states[i])) { STATE = state; return; } } throw new InvalidStateException(state); }
Upon compile I get this error.
Customer.java:193: cannot resolve symbol symbol : class InvalidStateException location: class Customer.Customer public void setSTATE (String state) throws InvalidStateException {
The "catch" is defined in the main function:
public static void main (String[] args) { Customer cust = new Customer(new BigDecimal("2")); cust.print(); try { cust.setSTATE("ZL"); } catch (InvalidStateException err) {} try { cust.setSTATE("MA"); } catch (InvalidStateException err) {}