diff --git a/core-java/pom.xml b/core-java/pom.xml
index e8548600f8..9c5a17d25c 100644
--- a/core-java/pom.xml
+++ b/core-java/pom.xml
@@ -216,8 +216,7 @@
true
-
+
org.baeldung.executable.ExecutableMavenJar
@@ -272,7 +271,7 @@
-Xmx300m
-XX:+UseParallelGC
-classpath
-
+
com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
@@ -338,7 +337,7 @@
java
-classpath
-
+
org.openjdk.jmh.Main
.*
@@ -371,8 +370,7 @@
true
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MF
@@ -406,14 +404,12 @@
true
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MF
com/baeldung/instrumentation/application/MyAtm.class
- com/baeldung/instrumentation/application/MyAtmApplication.class
-
+ com/baeldung/instrumentation/application/MyAtmApplication.class
com/baeldung/instrumentation/application/Launcher.class
@@ -443,14 +439,12 @@
true
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MF
com/baeldung/instrumentation/agent/AtmTransformer.class
- com/baeldung/instrumentation/agent/MyInstrumentationAgent.class
-
+ com/baeldung/instrumentation/agent/MyInstrumentationAgent.class
@@ -462,7 +456,6 @@
-
2.8.2
@@ -483,12 +476,10 @@
2.21.0
-
1.1
1.4.197
2.1.0.1
1.19
-
1.19
3.0.0-M1
3.0.2
@@ -499,7 +490,6 @@
61.1
3.21.0-GA
-
1.8.0
16.0.2
diff --git a/core-java/src/main/java/com/baeldung/nulls/APIContracts.java b/core-java/src/main/java/com/baeldung/nulls/APIContracts.java
index f8dfba25dd..7d6abf53b8 100644
--- a/core-java/src/main/java/com/baeldung/nulls/APIContracts.java
+++ b/core-java/src/main/java/com/baeldung/nulls/APIContracts.java
@@ -4,6 +4,7 @@ public class APIContracts {
/**
* Prints the value of {@code param} if not null. Prints {@code null} otherwise.
+ *
* @param param
*/
public void print(Object param) {
@@ -11,16 +12,16 @@ public class APIContracts {
}
/**
- *
* @return non null result
* @throws Exception - if result is null
*/
public Object process() throws Exception {
Object result = doSomething();
- if (result == null)
+ if (result == null) {
throw new Exception("Processing fail. Got a null response");
- else
+ } else {
return result;
+ }
}
private Object doSomething() {
diff --git a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java
index ff32db46dd..447026f1e3 100644
--- a/core-java/src/main/java/com/baeldung/nulls/Preconditions.java
+++ b/core-java/src/main/java/com/baeldung/nulls/Preconditions.java
@@ -3,22 +3,26 @@ package com.baeldung.nulls;
public class Preconditions {
public void goodAccept(String one, String two, String three) {
- if (null == one || null == two || three == null)
+ if (one == null || two == null || three == null)
throw new IllegalArgumentException();
+
+ process(one);
+ process(two);
+ process(three);
}
- public void badAccept(String one, String two, String three){
- if (null == one)
+ public void badAccept(String one, String two, String three) {
+ if (one == null)
throw new IllegalArgumentException();
else
process(one);
- if (null == two)
+ if (two == null)
throw new IllegalArgumentException();
else
process(two);
- if (null == three)
+ if (three == null)
throw new IllegalArgumentException();
else
process(three);
@@ -28,5 +32,4 @@ public class Preconditions {
private void process(String one) {
}
-
}
diff --git a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java
index dce7a05308..8f662b3760 100644
--- a/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java
+++ b/core-java/src/main/java/com/baeldung/nulls/PrimitivesAndWrapper.java
@@ -2,11 +2,11 @@ package com.baeldung.nulls;
public class PrimitivesAndWrapper {
- public static int sum(int a, int b) {
+ public static int primitiveSum(int a, int b) {
return a + b;
}
- public static Integer sum(Integer a, Integer b) {
+ public static Integer wrapperSum(Integer a, Integer b) {
return a + b;
}
@@ -17,8 +17,4 @@ public class PrimitivesAndWrapper {
throw new IllegalArgumentException();
}
- public static void main(String[] args) {
- sum(0, 0);
- sum(null, null);
- }
}
diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java
index e8a3262ce7..7383ae84a7 100644
--- a/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java
+++ b/core-java/src/main/java/com/baeldung/nulls/UsingObjects.java
@@ -4,21 +4,13 @@ import java.util.Objects;
public class UsingObjects {
- private String checked;
-
- public void accept(Object param) {
+ public void accept(Object param) throws Exception {
try {
Objects.requireNonNull(param);
} catch (NullPointerException e) {
- //doSomethingElseToo
- e.printStackTrace();
- }
- }
-
- public void caller() throws Exception {
- if (Objects.nonNull(checked))
- accept(checked);
- else
throw new Exception();
+ }
+
+ //doSomething()
}
}
diff --git a/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java b/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java
index 626afc311d..6c17290a72 100644
--- a/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java
+++ b/core-java/src/main/java/com/baeldung/nulls/UsingOptional.java
@@ -4,20 +4,24 @@ import java.util.Optional;
public class UsingOptional {
- public Optional