Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Java Programming/Keywords/throw

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

is a keyword; it 'throws' an exception. In a throw statement, the three types of objects that can be thrown are: Exception, java:Throwable, and java:Error Syntax: <Exception Ref>; For example: public Customer findCustomer( String name ) throws CustomerNotFoundException { Customer custRet = null; Iterator iter = _customerList.iterator(); while ( iter.hasNext() ) { Customer cust = (Customer) iter.next(); if ( cust.getName().equals( name ) ) { // --- Customer find -- custRet = cust; break; } } if ( custRet == null ) { // --- Customer not found --- throw new CustomerNotFoundException( "Customer "+ name + " was not found" ); } return custRet } See also Java Programming/Keywords/throws deep