Contents
Foreword
Preface
Fools ignore complexity; pragmatists suffer it; experts avoid it; | |
geniuses remove it. | |
Alan Perlis | |
% | |
People think that computer science is the art of geniuses but the | |
actual reality is the opposite, just many people doing things |
Optional<String> pathsStr = get(PATHS_KEY); | |
if (pathsStr.isPresent()) { | |
ObjectMapper objectMapper = new ObjectMapper(); | |
try { | |
String[] paths = objectMapper.readValue(pathsStr.get(), String[].class); | |
// ... the rest elided |
String zipCode = NullSafe.of(user) | |
.call(User::addresses) | |
.call(UserAddresses::billingAddress) | |
.call(Address::zipCode) | |
.get(); |
// standard java | |
String zipCode = null; | |
if(user != null) { | |
UserAddresses userAddresses = user.addresses(); | |
if(userAddresses != null) { | |
Address billingAddress = userAddresses.billingAddress(); | |
if (billingAddress != null) { | |
zipCode = billingAddress.zipCode(); | |
} | |
} |
int? length = customers?.Length; // null if customers is null | |
Customer first = customers?[0]; // null if customers is null | |
int? count = customers?[0]?.Orders?.Count(); // null if customers, the first customer, or Orders is null |
final Optional handle = (Optional)JAVA_9_PROCESSHANDLE_OF.invoke(null, pid); | |
if (handle.isPresent()) { | |
JAVA_9_PROCESSHANDLE_DESTROY.invoke(handle.get()); | |
} |
public void writeList() { | |
PrintWriter out = null; | |
try { | |
System.out.println("Entering" + " try statement"); | |
out = new PrintWriter(new FileWriter("OutFile.txt")); | |
for (int i = 0; i < SIZE; i++) { | |
out.println("Value at: " + i + " = " + list.get(i)); | |
} |
import java.util.PriorityQueue; | |
class Solution { | |
class ListNodeWrapper implements Comparable<ListNodeWrapper> { | |
int listNumber; | |
int val; | |
ListNodeWrapper(int listNumber, ListNode listNode) { | |
this.listNumber = listNumber; |