Elegant Java by Martin Hock

by Martin Hock · Views: 150 · Format: EPUB · Language: English (en)

Cover of Elegant Java by Martin Hock — Free EPUB on AnyEbooksEPUB

IllegalArgumentException Non-null parameter value is inappropriate IllegalStateException Object state is inappropriate for method invocation NullPointerException Parameter value is null where prohibited IndexOutOfBoundsException Index parameter value is out of range ConcurrentModificationException Concurrent modification of an object has been detected where it is prohibited UnsupportedOperationException Object does not support method 1.18 Validate method parameter Validate method arguments to ensure that they are within the scope of the intended design of the method. This practice ensures that operations on the parameters of the method provide valid results. Methods that accept arguments beyond a confidence boundary must perform a validation of their arguments. This precaution applies to all public methods of a class. Other methods, including private methods, should validate arguments that are both untrusted and not validated if these arguments from a public method can propagate through its arguments. Good code 1 public void concat ( String source , List concats , int startIndex ) { 2 if ( source == null || concats == null ) { 3 throw new IllegalArgumentException ( "source or concats cannot be null" ); 4 } 5 if ( startIndex >= concats . size () || startIndex < 0 ) { 6 throw new IllegalArgumentException ( "startIndex exceeds bounds of concats" ); 7 } 8 ... 9 } Objects.requireNonNull(obj) Objects.requireNonNull(obj, message) Objects.requireNonNull(obj, messageSupplie

★★★★★

Rate this eBook

File Name:04169c1f7fd69e9e3299629deddc4778.epub
Original Title:Elegant Java
Creator / Author:Martin Hock
Language:English (en)
Identifier:ASIN:301965
Publisher:Martin Hock Publishing
Category:Non-fiction
Format:📗 EPUB eBook
File Size:3.5 MB

Community Reviews

Loading verified community reviews...
✍️
Verified Author
View All Books by Author →

Related Non-fiction Titles