diff --git a/.travis.yml b/.travis.yml
index 683422dc97..5e86714a89 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,7 @@ before_install:
- echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit'" > ~/.mavenrc
install: skip
-script: travis_wait 60 mvn -q install -Pdefault-first,default-second
+script: travis_wait 60 mvn -q install -Pdefault-first,default-second -Dgib.enabled=true
sudo: required
diff --git a/JGit/src/main/java/com/baeldung/jgit/porcelain/Log.java b/JGit/src/main/java/com/baeldung/jgit/porcelain/Log.java
index cb476b9d9e..a50028a9ae 100644
--- a/JGit/src/main/java/com/baeldung/jgit/porcelain/Log.java
+++ b/JGit/src/main/java/com/baeldung/jgit/porcelain/Log.java
@@ -28,14 +28,14 @@ public class Log {
System.out.println("Had " + count + " commits overall on current branch");
logs = git.log()
- .add(repository.resolve("remotes/origin/testbranch"))
+ .add(repository.resolve(git.getRepository().getFullBranch()))
.call();
count = 0;
for (RevCommit rev : logs) {
System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */);
count++;
}
- System.out.println("Had " + count + " commits overall on test-branch");
+ System.out.println("Had " + count + " commits overall on "+git.getRepository().getFullBranch());
logs = git.log()
.all()
diff --git a/JGit/src/test/java/com/baeldung/jgit/JGitBugIntegrationTest.java b/JGit/src/test/java/com/baeldung/jgit/JGitBugIntegrationTest.java
index ed7168b2c2..ad34890996 100644
--- a/JGit/src/test/java/com/baeldung/jgit/JGitBugIntegrationTest.java
+++ b/JGit/src/test/java/com/baeldung/jgit/JGitBugIntegrationTest.java
@@ -1,3 +1,5 @@
+package com.baeldung.jgit;
+
import com.baeldung.jgit.helper.Helper;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.lib.ObjectReader;
diff --git a/akka-http/pom.xml b/akka-http/pom.xml
new file mode 100644
index 0000000000..51e70fb583
--- /dev/null
+++ b/akka-http/pom.xml
@@ -0,0 +1,48 @@
+
+
+
+ 4.0.0
+ akka-http
+ akka-http
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+
+
+
+ com.typesafe.akka
+ akka-http_2.12
+ ${akka.http.version}
+
+
+ com.typesafe.akka
+ akka-stream_2.12
+ 2.5.11
+
+
+ com.typesafe.akka
+ akka-http-jackson_2.12
+ ${akka.http.version}
+
+
+ com.typesafe.akka
+ akka-http-testkit_2.12
+ ${akka.http.version}
+ test
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 10.0.11
+ 2.5.11
+
+
diff --git a/akka-http/src/main/java/com/baeldung/akkahttp/User.java b/akka-http/src/main/java/com/baeldung/akkahttp/User.java
new file mode 100644
index 0000000000..43c21eca62
--- /dev/null
+++ b/akka-http/src/main/java/com/baeldung/akkahttp/User.java
@@ -0,0 +1,26 @@
+package com.baeldung.akkahttp;
+
+public class User {
+
+ private final Long id;
+
+ private final String name;
+
+ public User() {
+ this.name = "";
+ this.id = null;
+ }
+
+ public User(Long id, String name) {
+ this.name = name;
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+}
\ No newline at end of file
diff --git a/akka-http/src/main/java/com/baeldung/akkahttp/UserActor.java b/akka-http/src/main/java/com/baeldung/akkahttp/UserActor.java
new file mode 100644
index 0000000000..431014a88b
--- /dev/null
+++ b/akka-http/src/main/java/com/baeldung/akkahttp/UserActor.java
@@ -0,0 +1,41 @@
+package com.baeldung.akkahttp;
+
+import akka.actor.AbstractActor;
+import akka.actor.Props;
+import akka.japi.pf.FI;
+import com.baeldung.akkahttp.UserMessages.ActionPerformed;
+import com.baeldung.akkahttp.UserMessages.CreateUserMessage;
+import com.baeldung.akkahttp.UserMessages.GetUserMessage;
+
+
+class UserActor extends AbstractActor {
+
+ private UserService userService = new UserService();
+
+ static Props props() {
+ return Props.create(UserActor.class);
+ }
+
+ @Override
+ public Receive createReceive() {
+ return receiveBuilder()
+ .match(CreateUserMessage.class, handleCreateUser())
+ .match(GetUserMessage.class, handleGetUser())
+ .build();
+ }
+
+ private FI.UnitApply handleCreateUser() {
+ return createUserMessageMessage -> {
+ userService.createUser(createUserMessageMessage.getUser());
+ sender().tell(new ActionPerformed(String.format("User %s created.", createUserMessageMessage.getUser()
+ .getName())), getSelf());
+ };
+ }
+
+ private FI.UnitApply handleGetUser() {
+ return getUserMessageMessage -> {
+ sender().tell(userService.getUser(getUserMessageMessage.getUserId()), getSelf());
+ };
+ }
+
+}
diff --git a/akka-http/src/main/java/com/baeldung/akkahttp/UserMessages.java b/akka-http/src/main/java/com/baeldung/akkahttp/UserMessages.java
new file mode 100644
index 0000000000..995b92bcb0
--- /dev/null
+++ b/akka-http/src/main/java/com/baeldung/akkahttp/UserMessages.java
@@ -0,0 +1,49 @@
+package com.baeldung.akkahttp;
+
+import java.io.Serializable;
+
+public interface UserMessages {
+
+ class ActionPerformed implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String description;
+
+ public ActionPerformed(String description) {
+ this.description = description;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ }
+
+ class CreateUserMessage implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private final User user;
+
+ public CreateUserMessage(User user) {
+ this.user = user;
+ }
+
+ public User getUser() {
+ return user;
+ }
+ }
+
+ class GetUserMessage implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final Long userId;
+
+ public GetUserMessage(Long userId) {
+ this.userId = userId;
+ }
+
+ public Long getUserId() {
+ return userId;
+ }
+ }
+
+}
diff --git a/akka-http/src/main/java/com/baeldung/akkahttp/UserServer.java b/akka-http/src/main/java/com/baeldung/akkahttp/UserServer.java
new file mode 100644
index 0000000000..0c1dbd1f60
--- /dev/null
+++ b/akka-http/src/main/java/com/baeldung/akkahttp/UserServer.java
@@ -0,0 +1,70 @@
+package com.baeldung.akkahttp;
+
+import java.util.Optional;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.TimeUnit;
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.http.javadsl.marshallers.jackson.Jackson;
+import akka.http.javadsl.model.StatusCodes;
+import akka.http.javadsl.server.HttpApp;
+import akka.http.javadsl.server.Route;
+import akka.pattern.PatternsCS;
+import akka.util.Timeout;
+import com.baeldung.akkahttp.UserMessages.ActionPerformed;
+import com.baeldung.akkahttp.UserMessages.CreateUserMessage;
+import com.baeldung.akkahttp.UserMessages.GetUserMessage;
+import scala.concurrent.duration.Duration;
+import static akka.http.javadsl.server.PathMatchers.*;
+
+class UserServer extends HttpApp {
+
+ private final ActorRef userActor;
+
+ Timeout timeout = new Timeout(Duration.create(5, TimeUnit.SECONDS));
+
+ UserServer(ActorRef userActor) {
+ this.userActor = userActor;
+ }
+
+ @Override
+ public Route routes() {
+ return path("users", this::postUser)
+ .orElse(path(segment("users").slash(longSegment()), id ->
+ route(getUser(id))));
+ }
+
+ private Route getUser(Long id) {
+ return get(() -> {
+ CompletionStage> user = PatternsCS.ask(userActor, new GetUserMessage(id), timeout)
+ .thenApply(obj -> (Optional) obj);
+
+ return onSuccess(() -> user, performed -> {
+ if (performed.isPresent())
+ return complete(StatusCodes.OK, performed.get(), Jackson.marshaller());
+ else
+ return complete(StatusCodes.NOT_FOUND);
+ });
+ });
+ }
+
+ private Route postUser() {
+ return route(post(() -> entity(Jackson.unmarshaller(User.class), user -> {
+ CompletionStage userCreated = PatternsCS.ask(userActor, new CreateUserMessage(user), timeout)
+ .thenApply(obj -> (ActionPerformed) obj);
+
+ return onSuccess(() -> userCreated, performed -> {
+ return complete(StatusCodes.CREATED, performed, Jackson.marshaller());
+ });
+ })));
+ }
+
+ public static void main(String[] args) throws Exception {
+ ActorSystem system = ActorSystem.create("userServer");
+ ActorRef userActor = system.actorOf(UserActor.props(), "userActor");
+ UserServer server = new UserServer(userActor);
+ server.startServer("localhost", 8080, system);
+ }
+
+}
diff --git a/akka-http/src/main/java/com/baeldung/akkahttp/UserService.java b/akka-http/src/main/java/com/baeldung/akkahttp/UserService.java
new file mode 100644
index 0000000000..50dc1e1b28
--- /dev/null
+++ b/akka-http/src/main/java/com/baeldung/akkahttp/UserService.java
@@ -0,0 +1,35 @@
+package com.baeldung.akkahttp;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+public class UserService {
+
+ private final static List users = new ArrayList<>();
+
+ static {
+ users.add(new User(1l, "Alice"));
+ users.add(new User(2l, "Bob"));
+ users.add(new User(3l, "Chris"));
+ users.add(new User(4l, "Dick"));
+ users.add(new User(5l, "Eve"));
+ users.add(new User(6l, "Finn"));
+ }
+
+ public Optional getUser(Long id) {
+ return users.stream()
+ .filter(user -> user.getId()
+ .equals(id))
+ .findFirst();
+ }
+
+ public void createUser(User user) {
+ users.add(user);
+ }
+
+ public List getUsers(){
+ return users;
+ }
+
+}
diff --git a/akka-http/src/test/java/com/baeldung/akkahttp/UserServerUnitTest.java b/akka-http/src/test/java/com/baeldung/akkahttp/UserServerUnitTest.java
new file mode 100644
index 0000000000..1170a2d761
--- /dev/null
+++ b/akka-http/src/test/java/com/baeldung/akkahttp/UserServerUnitTest.java
@@ -0,0 +1,50 @@
+package com.baeldung.akkahttp;
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.http.javadsl.model.ContentTypes;
+import akka.http.javadsl.model.HttpEntities;
+import akka.http.javadsl.model.HttpRequest;
+import akka.http.javadsl.testkit.JUnitRouteTest;
+import akka.http.javadsl.testkit.TestRoute;
+import org.junit.Test;
+
+public class UserServerUnitTest extends JUnitRouteTest {
+
+ ActorSystem system = ActorSystem.create("helloAkkaHttpServer");
+
+ ActorRef userActorRef = system.actorOf(UserActor.props(), "userActor");
+
+ TestRoute appRoute = testRoute(new UserServer(userActorRef).routes());
+
+ @Test
+ public void whenRequest_thenActorResponds() {
+
+ appRoute.run(HttpRequest.GET("/users/1"))
+ .assertEntity(alice())
+ .assertStatusCode(200);
+
+ appRoute.run(HttpRequest.GET("/users/42"))
+ .assertStatusCode(404);
+
+ appRoute.run(HttpRequest.DELETE("/users/1"))
+ .assertStatusCode(200);
+
+ appRoute.run(HttpRequest.DELETE("/users/42"))
+ .assertStatusCode(200);
+
+ appRoute.run(HttpRequest.POST("/users")
+ .withEntity(HttpEntities.create(ContentTypes.APPLICATION_JSON, zaphod())))
+ .assertStatusCode(201);
+
+ }
+
+ private String alice() {
+ return "{\"id\":1,\"name\":\"Alice\"}";
+ }
+
+ private String zaphod() {
+ return "{\"id\":42,\"name\":\"Zaphod\"}";
+ }
+
+}
diff --git a/algorithms-genetic/pom.xml b/algorithms-genetic/pom.xml
index 2a10a81980..fc6d36dac1 100644
--- a/algorithms-genetic/pom.xml
+++ b/algorithms-genetic/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldungalgorithms-genetic0.0.1-SNAPSHOT
-
+ algorithms-genetic
+
com.baeldungparent-modules
@@ -61,4 +61,5 @@
1.11
-
\ No newline at end of file
+
+
diff --git a/algorithms-miscellaneous-1/README.md b/algorithms-miscellaneous-1/README.md
index a04874c4d2..a725bbd141 100644
--- a/algorithms-miscellaneous-1/README.md
+++ b/algorithms-miscellaneous-1/README.md
@@ -10,4 +10,6 @@
- [Multi-Swarm Optimization Algorithm in Java](http://www.baeldung.com/java-multi-swarm-algorithm)
- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
-- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)
\ No newline at end of file
+- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)
+- [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial)
+- [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings)
\ No newline at end of file
diff --git a/algorithms-miscellaneous-1/pom.xml b/algorithms-miscellaneous-1/pom.xml
index 16749d452e..5006670dd9 100644
--- a/algorithms-miscellaneous-1/pom.xml
+++ b/algorithms-miscellaneous-1/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldungalgorithms-miscellaneous-10.0.1-SNAPSHOT
-
+ algorithms-miscellaneous-1
+
com.baeldungparent-modules
@@ -17,6 +17,11 @@
commons-math3${commons-math3.version}
+
+ com.google.guava
+ guava
+ ${guava.version}
+ commons-codeccommons-codec
@@ -73,6 +78,7 @@
3.6.13.9.01.11
+ 25.1-jre
\ No newline at end of file
diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/factorial/Factorial.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/factorial/Factorial.java
new file mode 100644
index 0000000000..43d2221773
--- /dev/null
+++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/factorial/Factorial.java
@@ -0,0 +1,63 @@
+package com.baeldung.algorithms.factorial;
+
+import java.math.BigInteger;
+import java.util.stream.LongStream;
+
+import org.apache.commons.math3.util.CombinatoricsUtils;
+
+import com.google.common.math.BigIntegerMath;
+
+public class Factorial {
+
+ public long factorialUsingForLoop(int n) {
+ long fact = 1;
+ for (int i = 2; i <= n; i++) {
+ fact = fact * i;
+ }
+ return fact;
+ }
+
+ public long factorialUsingStreams(int n) {
+ return LongStream.rangeClosed(1, n)
+ .reduce(1, (long x, long y) -> x * y);
+ }
+
+ public long factorialUsingRecursion(int n) {
+ if (n <= 2) {
+ return n;
+ }
+ return n * factorialUsingRecursion(n - 1);
+ }
+
+ private Long[] factorials = new Long[20];
+
+ public long factorialUsingMemoize(int n) {
+
+ if (factorials[n] != null) {
+ return factorials[n];
+ }
+
+ if (n <= 2) {
+ return n;
+ }
+ long nthValue = n * factorialUsingMemoize(n - 1);
+ factorials[n] = nthValue;
+ return nthValue;
+ }
+
+ public BigInteger factorialHavingLargeResult(int n) {
+ BigInteger result = BigInteger.ONE;
+ for (int i = 2; i <= n; i++)
+ result = result.multiply(BigInteger.valueOf(i));
+ return result;
+ }
+
+ public long factorialUsingApacheCommons(int n) {
+ return CombinatoricsUtils.factorial(n);
+ }
+
+ public BigInteger factorialUsingGuava(int n) {
+ return BigIntegerMath.factorial(n);
+ }
+
+}
diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/LongestSubstringNonRepeatingCharacters.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/LongestSubstringNonRepeatingCharacters.java
new file mode 100644
index 0000000000..cd1f3e94d5
--- /dev/null
+++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/LongestSubstringNonRepeatingCharacters.java
@@ -0,0 +1,54 @@
+package com.baeldung.algorithms.string;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class LongestSubstringNonRepeatingCharacters {
+
+ public static String getUniqueCharacterSubstringBruteForce(String input) {
+ String output = "";
+ for (int start = 0; start < input.length(); start++) {
+ Set visited = new HashSet<>();
+ int end = start;
+ for (; end < input.length(); end++) {
+ char currChar = input.charAt(end);
+ if (visited.contains(currChar)) {
+ break;
+ } else {
+ visited.add(currChar);
+ }
+ }
+ if (output.length() < end - start + 1) {
+ output = input.substring(start, end);
+ }
+ }
+ return output;
+ }
+
+ public static String getUniqueCharacterSubstring(String input) {
+ Map visited = new HashMap<>();
+ String output = "";
+ for (int start = 0, end = 0; end < input.length(); end++) {
+ char currChar = input.charAt(end);
+ if (visited.containsKey(currChar)) {
+ start = Math.max(visited.get(currChar) + 1, start);
+ }
+ if (output.length() < end - start + 1) {
+ output = input.substring(start, end + 1);
+ }
+ visited.put(currChar, end);
+ }
+ return output;
+ }
+
+ public static void main(String[] args) {
+ if(args.length > 0) {
+ System.out.println(getUniqueCharacterSubstring(args[0]));
+ } else {
+ System.err.println("This program expects command-line input. Please try again!");
+ }
+ }
+
+}
diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/SubstringPalindrome.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/SubstringPalindrome.java
new file mode 100644
index 0000000000..b3d142eb07
--- /dev/null
+++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/SubstringPalindrome.java
@@ -0,0 +1,90 @@
+package com.baeldung.algorithms.string;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class SubstringPalindrome {
+
+ public Set findAllPalindromesUsingCenter(String input) {
+ final Set palindromes = new HashSet<>();
+ if (input == null || input.isEmpty()) {
+ return palindromes;
+ }
+ if (input.length() == 1) {
+ palindromes.add(input);
+ return palindromes;
+ }
+ for (int i = 0; i < input.length(); i++) {
+ palindromes.addAll(findPalindromes(input, i, i + 1));
+ palindromes.addAll(findPalindromes(input, i, i));
+ }
+ return palindromes;
+ }
+
+ private Set findPalindromes(String input, int low, int high) {
+ Set result = new HashSet<>();
+ while (low >= 0 && high < input.length() && input.charAt(low) == input.charAt(high)) {
+ result.add(input.substring(low, high + 1));
+ low--;
+ high++;
+ }
+ return result;
+ }
+
+ public Set findAllPalindromesUsingBruteForceApproach(String input) {
+ Set palindromes = new HashSet<>();
+ if (input == null || input.isEmpty()) {
+ return palindromes;
+ }
+ if (input.length() == 1) {
+ palindromes.add(input);
+ return palindromes;
+ }
+ for (int i = 0; i < input.length(); i++) {
+ for (int j = i + 1; j <= input.length(); j++)
+ if (isPalindrome(input.substring(i, j))) {
+ palindromes.add(input.substring(i, j));
+ }
+ }
+ return palindromes;
+ }
+
+ private boolean isPalindrome(String input) {
+ StringBuilder plain = new StringBuilder(input);
+ StringBuilder reverse = plain.reverse();
+ return (reverse.toString()).equals(input);
+ }
+
+ public Set findAllPalindromesUsingManachersAlgorithm(String input) {
+ Set palindromes = new HashSet<>();
+ String formattedInput = "@" + input + "#";
+ char inputCharArr[] = formattedInput.toCharArray();
+ int max;
+ int radius[][] = new int[2][input.length() + 1];
+ for (int j = 0; j <= 1; j++) {
+ radius[j][0] = max = 0;
+ int i = 1;
+ while (i <= input.length()) {
+ palindromes.add(Character.toString(inputCharArr[i]));
+ while (inputCharArr[i - max - 1] == inputCharArr[i + j + max])
+ max++;
+ radius[j][i] = max;
+ int k = 1;
+ while ((radius[j][i - k] != max - k) && (k < max)) {
+ radius[j][i + k] = Math.min(radius[j][i - k], max - k);
+ k++;
+ }
+ max = Math.max(max - k, 0);
+ i += k;
+ }
+ }
+ for (int i = 1; i <= input.length(); i++) {
+ for (int j = 0; j <= 1; j++) {
+ for (max = radius[j][i]; max > 0; max--) {
+ palindromes.add(input.substring(i - max - 1, max + j + i - 1));
+ }
+ }
+ }
+ return palindromes;
+ }
+}
diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/factorial/FactorialUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/factorial/FactorialUnitTest.java
new file mode 100644
index 0000000000..c185dba62b
--- /dev/null
+++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/factorial/FactorialUnitTest.java
@@ -0,0 +1,72 @@
+package com.baeldung.algorithms.factorial;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.math.BigInteger;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class FactorialUnitTest {
+
+ Factorial factorial;
+
+ @Before
+ public void setup() {
+ factorial = new Factorial();
+ }
+
+ @Test
+ public void whenCalculatingFactorialUsingForLoop_thenCorrect() {
+ int n = 5;
+
+ assertThat(factorial.factorialUsingForLoop(n)).isEqualTo(120);
+ }
+
+ @Test
+ public void whenCalculatingFactorialUsingStreams_thenCorrect() {
+ int n = 5;
+
+ assertThat(factorial.factorialUsingStreams(n)).isEqualTo(120);
+ }
+
+ @Test
+ public void whenCalculatingFactorialUsingRecursion_thenCorrect() {
+ int n = 5;
+
+ assertThat(factorial.factorialUsingRecursion(n)).isEqualTo(120);
+ }
+
+ @Test
+ public void whenCalculatingFactorialUsingMemoize_thenCorrect() {
+ int n = 5;
+
+ assertThat(factorial.factorialUsingMemoize(n)).isEqualTo(120);
+
+ n = 6;
+
+ assertThat(factorial.factorialUsingMemoize(n)).isEqualTo(720);
+ }
+
+ @Test
+ public void whenCalculatingFactorialHavingLargeResult_thenCorrect() {
+ int n = 22;
+
+ assertThat(factorial.factorialHavingLargeResult(n)).isEqualTo(new BigInteger("1124000727777607680000"));
+ }
+
+ @Test
+ public void whenCalculatingFactorialUsingApacheCommons_thenCorrect() {
+ int n = 5;
+
+ assertThat(factorial.factorialUsingApacheCommons(n)).isEqualTo(120);
+ }
+
+ @Test
+ public void whenCalculatingFactorialUsingGuava_thenCorrect() {
+ int n = 22;
+
+ assertThat(factorial.factorialUsingGuava(n)).isEqualTo(new BigInteger("1124000727777607680000"));
+ }
+
+}
diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/LongestSubstringNonRepeatingCharactersUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/LongestSubstringNonRepeatingCharactersUnitTest.java
new file mode 100644
index 0000000000..9f1e6a2519
--- /dev/null
+++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/LongestSubstringNonRepeatingCharactersUnitTest.java
@@ -0,0 +1,31 @@
+package com.baeldung.algorithms.string;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static com.baeldung.algorithms.string.LongestSubstringNonRepeatingCharacters.getUniqueCharacterSubstring;
+import static com.baeldung.algorithms.string.LongestSubstringNonRepeatingCharacters.getUniqueCharacterSubstringBruteForce;
+
+public class LongestSubstringNonRepeatingCharactersUnitTest {
+
+ @Test
+ void givenString_whenGetUniqueCharacterSubstringBruteForceCalled_thenResultFoundAsExpectedUnitTest() {
+ assertEquals("", getUniqueCharacterSubstringBruteForce(""));
+ assertEquals("A", getUniqueCharacterSubstringBruteForce("A"));
+ assertEquals("ABCDEF", getUniqueCharacterSubstringBruteForce("AABCDEF"));
+ assertEquals("ABCDEF", getUniqueCharacterSubstringBruteForce("ABCDEFF"));
+ assertEquals("NGISAWE", getUniqueCharacterSubstringBruteForce("CODINGISAWESOME"));
+ assertEquals("be coding", getUniqueCharacterSubstringBruteForce("always be coding"));
+ }
+
+ @Test
+ void givenString_whenGetUniqueCharacterSubstringCalled_thenResultFoundAsExpectedUnitTest() {
+ assertEquals("", getUniqueCharacterSubstring(""));
+ assertEquals("A", getUniqueCharacterSubstring("A"));
+ assertEquals("ABCDEF", getUniqueCharacterSubstring("AABCDEF"));
+ assertEquals("ABCDEF", getUniqueCharacterSubstring("ABCDEFF"));
+ assertEquals("NGISAWE", getUniqueCharacterSubstring("CODINGISAWESOME"));
+ assertEquals("be coding", getUniqueCharacterSubstring("always be coding"));
+ }
+
+}
diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/SubstringPalindromeUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/SubstringPalindromeUnitTest.java
new file mode 100644
index 0000000000..8d225f67fa
--- /dev/null
+++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/SubstringPalindromeUnitTest.java
@@ -0,0 +1,83 @@
+package com.baeldung.algorithms.string;
+
+import static org.junit.Assert.assertEquals;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+
+public class SubstringPalindromeUnitTest {
+
+ private static final String INPUT_BUBBLE = "bubble";
+ private static final String INPUT_CIVIC = "civic";
+ private static final String INPUT_INDEED = "indeed";
+ private static final String INPUT_ABABAC = "ababac";
+
+ Set EXPECTED_PALINDROME_BUBBLE = new HashSet() {
+ {
+ add("b");
+ add("u");
+ add("l");
+ add("e");
+ add("bb");
+ add("bub");
+ }
+ };
+
+ Set EXPECTED_PALINDROME_CIVIC = new HashSet() {
+ {
+ add("civic");
+ add("ivi");
+ add("i");
+ add("c");
+ add("v");
+ }
+ };
+
+ Set EXPECTED_PALINDROME_INDEED = new HashSet() {
+ {
+ add("i");
+ add("n");
+ add("d");
+ add("e");
+ add("ee");
+ add("deed");
+ }
+ };
+
+ Set EXPECTED_PALINDROME_ABABAC = new HashSet() {
+ {
+ add("a");
+ add("b");
+ add("c");
+ add("aba");
+ add("bab");
+ add("ababa");
+ }
+ };
+
+ private SubstringPalindrome palindrome = new SubstringPalindrome();
+
+ @Test
+ public void whenUsingManachersAlgorithm_thenFindsAllPalindromes() {
+ assertEquals(EXPECTED_PALINDROME_BUBBLE, palindrome.findAllPalindromesUsingManachersAlgorithm(INPUT_BUBBLE));
+ assertEquals(EXPECTED_PALINDROME_INDEED, palindrome.findAllPalindromesUsingManachersAlgorithm(INPUT_INDEED));
+ assertEquals(EXPECTED_PALINDROME_CIVIC, palindrome.findAllPalindromesUsingManachersAlgorithm(INPUT_CIVIC));
+ assertEquals(EXPECTED_PALINDROME_ABABAC, palindrome.findAllPalindromesUsingManachersAlgorithm(INPUT_ABABAC));
+ }
+
+ @Test
+ public void whenUsingCenterApproach_thenFindsAllPalindromes() {
+ assertEquals(EXPECTED_PALINDROME_BUBBLE, palindrome.findAllPalindromesUsingCenter(INPUT_BUBBLE));
+ assertEquals(EXPECTED_PALINDROME_INDEED, palindrome.findAllPalindromesUsingCenter(INPUT_INDEED));
+ assertEquals(EXPECTED_PALINDROME_CIVIC, palindrome.findAllPalindromesUsingCenter(INPUT_CIVIC));
+ assertEquals(EXPECTED_PALINDROME_ABABAC, palindrome.findAllPalindromesUsingCenter(INPUT_ABABAC));
+ }
+
+ @Test
+ public void whenUsingBruteForceApproach_thenFindsAllPalindromes() {
+ assertEquals(EXPECTED_PALINDROME_BUBBLE, palindrome.findAllPalindromesUsingBruteForceApproach(INPUT_BUBBLE));
+ assertEquals(EXPECTED_PALINDROME_INDEED, palindrome.findAllPalindromesUsingBruteForceApproach(INPUT_INDEED));
+ assertEquals(EXPECTED_PALINDROME_CIVIC, palindrome.findAllPalindromesUsingBruteForceApproach(INPUT_CIVIC));
+ assertEquals(EXPECTED_PALINDROME_ABABAC, palindrome.findAllPalindromesUsingBruteForceApproach(INPUT_ABABAC));
+ }
+}
diff --git a/algorithms-miscellaneous-2/README.md b/algorithms-miscellaneous-2/README.md
index 6772a94a8d..d693a44f66 100644
--- a/algorithms-miscellaneous-2/README.md
+++ b/algorithms-miscellaneous-2/README.md
@@ -17,3 +17,4 @@
- [Round Up to the Nearest Hundred](https://www.baeldung.com/java-round-up-nearest-hundred)
- [Calculate Percentage in Java](https://www.baeldung.com/java-calculate-percentage)
- [Converting Between Byte Arrays and Hexadecimal Strings in Java](https://www.baeldung.com/java-byte-arrays-hex-strings)
+- [Convert Latitude and Longitude to a 2D Point in Java](https://www.baeldung.com/java-convert-latitude-longitude)
diff --git a/algorithms-miscellaneous-2/pom.xml b/algorithms-miscellaneous-2/pom.xml
index eeae544612..5461f4ebe1 100644
--- a/algorithms-miscellaneous-2/pom.xml
+++ b/algorithms-miscellaneous-2/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldungalgorithms-miscellaneous-20.0.1-SNAPSHOT
+ algorithms-miscellaneous-2com.baeldung
@@ -33,6 +33,11 @@
jgrapht-core${org.jgrapht.core.version}
+
+ org.jgrapht
+ jgrapht-ext
+ ${org.jgrapht.ext.version}
+ pl.allegro.financetradukisto
@@ -83,6 +88,7 @@
3.6.11.0.11.0.1
+ 1.0.13.9.01.11
diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java
new file mode 100644
index 0000000000..3b841d574a
--- /dev/null
+++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java
@@ -0,0 +1,47 @@
+package com.baeldung.jgrapht;
+
+import static org.junit.Assert.assertTrue;
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+import org.jgrapht.ext.JGraphXAdapter;
+import org.jgrapht.graph.DefaultDirectedGraph;
+import org.jgrapht.graph.DefaultEdge;
+import org.junit.Before;
+import org.junit.Test;
+import com.mxgraph.layout.mxCircleLayout;
+import com.mxgraph.layout.mxIGraphLayout;
+import com.mxgraph.util.mxCellRenderer;
+
+public class GraphImageGenerationUnitTest {
+ static DefaultDirectedGraph g;
+
+ @Before
+ public void createGraph() throws IOException {
+ File imgFile = new File("src/test/resources/graph.png");
+ imgFile.createNewFile();
+ g = new DefaultDirectedGraph(DefaultEdge.class);
+ String x1 = "x1";
+ String x2 = "x2";
+ String x3 = "x3";
+ g.addVertex(x1);
+ g.addVertex(x2);
+ g.addVertex(x3);
+ g.addEdge(x1, x2);
+ g.addEdge(x2, x3);
+ g.addEdge(x3, x1);
+ }
+
+ @Test
+ public void givenAdaptedGraph_whenWriteBufferedImage_ThenFileShouldExist() throws IOException {
+ JGraphXAdapter graphAdapter = new JGraphXAdapter(g);
+ mxIGraphLayout layout = new mxCircleLayout(graphAdapter);
+ layout.execute(graphAdapter.getDefaultParent());
+ File imgFile = new File("src/test/resources/graph.png");
+ BufferedImage image = mxCellRenderer.createBufferedImage(graphAdapter, null, 2, Color.WHITE, true, null);
+ ImageIO.write(image, "PNG", imgFile);
+ assertTrue(imgFile.exists());
+ }
+}
\ No newline at end of file
diff --git a/algorithms-miscellaneous-2/src/test/resources/graph.png b/algorithms-miscellaneous-2/src/test/resources/graph.png
new file mode 100644
index 0000000000..56995b8dd9
Binary files /dev/null and b/algorithms-miscellaneous-2/src/test/resources/graph.png differ
diff --git a/algorithms-sorting/pom.xml b/algorithms-sorting/pom.xml
index 60ae37f2a4..2aee6e9199 100644
--- a/algorithms-sorting/pom.xml
+++ b/algorithms-sorting/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldungalgorithms-sorting0.0.1-SNAPSHOT
+ algorithms-sortingcom.baeldung
diff --git a/algorithms-sorting/src/main/java/com/baeldung/algorithms/mergesort/MergeSort.java b/algorithms-sorting/src/main/java/com/baeldung/algorithms/mergesort/MergeSort.java
index 0deb48b6a0..945b4ffd7e 100644
--- a/algorithms-sorting/src/main/java/com/baeldung/algorithms/mergesort/MergeSort.java
+++ b/algorithms-sorting/src/main/java/com/baeldung/algorithms/mergesort/MergeSort.java
@@ -34,7 +34,7 @@ public class MergeSort {
while (i < left && j < right) {
- if (l[i] < r[j])
+ if (l[i] <= r[j])
a[k++] = l[i++];
else
a[k++] = r[j++];
diff --git a/annotations/annotation-processing/pom.xml b/annotations/annotation-processing/pom.xml
index 8e53334521..d9aca6040d 100644
--- a/annotations/annotation-processing/pom.xml
+++ b/annotations/annotation-processing/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0annotation-processing
-
+ annotation-processing
+
com.baeldung1.0.0-SNAPSHOT
diff --git a/annotations/annotation-user/pom.xml b/annotations/annotation-user/pom.xml
index 07ea9a5b5a..422cc7f119 100644
--- a/annotations/annotation-user/pom.xml
+++ b/annotations/annotation-user/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0annotation-user
+ annotation-userannotations
diff --git a/annotations/pom.xml b/annotations/pom.xml
index 2c73d3d91b..6d83f5b057 100644
--- a/annotations/pom.xml
+++ b/annotations/pom.xml
@@ -4,7 +4,8 @@
4.0.0annotationspom
-
+ annotations
+
parent-modulescom.baeldung
diff --git a/apache-avro/pom.xml b/apache-avro/pom.xml
index ddf5844271..18f9c34d64 100644
--- a/apache-avro/pom.xml
+++ b/apache-avro/pom.xml
@@ -3,10 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.baeldungapache-avro0.0.1-SNAPSHOT
- Apache Avro
+ apache-avroUTF-8
diff --git a/apache-bval/pom.xml b/apache-bval/pom.xml
index 5ddb1ecb59..786f587fb1 100644
--- a/apache-bval/pom.xml
+++ b/apache-bval/pom.xml
@@ -4,7 +4,8 @@
apache-bvalapache-bval0.0.1-SNAPSHOT
-
+ apache-bval
+
com.baeldungparent-modules
diff --git a/apache-curator/pom.xml b/apache-curator/pom.xml
index ac10811e7a..e6be32277d 100644
--- a/apache-curator/pom.xml
+++ b/apache-curator/pom.xml
@@ -4,6 +4,7 @@
apache-curator0.0.1-SNAPSHOTjar
+ apache-curatorcom.baeldung
@@ -58,7 +59,7 @@
4.0.13.4.11
- 2.9.4
+ 2.9.73.6.11.7.0
diff --git a/apache-cxf/cxf-aegis/pom.xml b/apache-cxf/cxf-aegis/pom.xml
index b7e9e426a2..1d36178b82 100644
--- a/apache-cxf/cxf-aegis/pom.xml
+++ b/apache-cxf/cxf-aegis/pom.xml
@@ -2,7 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0cxf-aegis
-
+ cxf-aegis
+
com.baeldungapache-cxf
diff --git a/apache-cxf/cxf-introduction/pom.xml b/apache-cxf/cxf-introduction/pom.xml
index a9e82c16b3..17f03afd25 100644
--- a/apache-cxf/cxf-introduction/pom.xml
+++ b/apache-cxf/cxf-introduction/pom.xml
@@ -4,7 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0cxf-introduction
-
+ cxf-introduction
+
com.baeldungapache-cxf
diff --git a/apache-cxf/cxf-jaxrs-implementation/pom.xml b/apache-cxf/cxf-jaxrs-implementation/pom.xml
index 89acbdf1bd..03d0f67c90 100644
--- a/apache-cxf/cxf-jaxrs-implementation/pom.xml
+++ b/apache-cxf/cxf-jaxrs-implementation/pom.xml
@@ -4,7 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0cxf-jaxrs-implementation
-
+ cxf-jaxrs-implementation
+
com.baeldungapache-cxf
diff --git a/apache-cxf/cxf-spring/pom.xml b/apache-cxf/cxf-spring/pom.xml
index 31e75e7cdd..97715af54c 100644
--- a/apache-cxf/cxf-spring/pom.xml
+++ b/apache-cxf/cxf-spring/pom.xml
@@ -3,6 +3,7 @@
4.0.0cxf-springwar
+ cxf-springcom.baeldung
diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml
index 8918fd4450..0016f33d70 100644
--- a/apache-cxf/pom.xml
+++ b/apache-cxf/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldungapache-cxf0.0.1-SNAPSHOT
+ apache-cxfpom
diff --git a/apache-cxf/sse-jaxrs/pom.xml b/apache-cxf/sse-jaxrs/pom.xml
index d4b6c19d03..cb5c96660a 100644
--- a/apache-cxf/sse-jaxrs/pom.xml
+++ b/apache-cxf/sse-jaxrs/pom.xml
@@ -3,8 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
sse-jaxrs
+ sse-jaxrspom
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
index 0f5406fbc7..c7acf22c32 100644
--- a/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
@@ -3,15 +3,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
+ sse-jaxrs-client
+ sse-jaxrs-client
+
com.baeldungsse-jaxrs0.0.1-SNAPSHOT
- sse-jaxrs-client
-
3.2.0
@@ -21,7 +21,6 @@
org.codehaus.mojoexec-maven-plugin
- 1.6.0singleEvent
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
index 2e82dc3829..eeb5726ee1 100644
--- a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
@@ -3,16 +3,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
+ sse-jaxrs-server
+ sse-jaxrs-server
+ war
+
com.baeldungsse-jaxrs0.0.1-SNAPSHOT
- sse-jaxrs-server
- war
-
2.4.2false
diff --git a/apache-geode/pom.xml b/apache-geode/pom.xml
index a3f6604ac4..738accdcb8 100644
--- a/apache-geode/pom.xml
+++ b/apache-geode/pom.xml
@@ -3,11 +3,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
- com.baeldungapache-geode1.0-SNAPSHOT
-
+ apache-geode
+
com.baeldungparent-modules
diff --git a/apache-opennlp/pom.xml b/apache-opennlp/pom.xml
index 985c9a2df2..6b2e6a9729 100644
--- a/apache-opennlp/pom.xml
+++ b/apache-opennlp/pom.xml
@@ -4,6 +4,7 @@
4.0.0apache-opennlp1.0-SNAPSHOT
+ apache-opennlpjar
diff --git a/apache-poi/pom.xml b/apache-poi/pom.xml
index a1ec626d43..54c3e8e928 100644
--- a/apache-poi/pom.xml
+++ b/apache-poi/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldungapache-poi0.0.1-SNAPSHOT
+ apache-poicom.baeldung
diff --git a/apache-pulsar/pom.xml b/apache-pulsar/pom.xml
index da004a7638..a4c09586eb 100644
--- a/apache-pulsar/pom.xml
+++ b/apache-pulsar/pom.xml
@@ -1,21 +1,22 @@
- 4.0.0
- com.baeldung.pulsar
- pulsar-java
- 0.0.1
+ 4.0.0
+ com.baeldung.pulsar
+ apache-pulsar
+ 0.0.1
+ apache-pulsar
-
-
- org.apache.pulsar
- pulsar-client
- 2.1.1-incubating
- compile
-
-
-
- 1.8
- 1.8
-
+
+
+ org.apache.pulsar
+ pulsar-client
+ 2.1.1-incubating
+ compile
+
+
+
+ 1.8
+ 1.8
+
diff --git a/apache-shiro/pom.xml b/apache-shiro/pom.xml
index 98d9563284..644d70b30a 100644
--- a/apache-shiro/pom.xml
+++ b/apache-shiro/pom.xml
@@ -5,7 +5,8 @@
4.0.0apache-shiro1.0-SNAPSHOT
-
+ apache-shiro
+
parent-boot-1com.baeldung
diff --git a/apache-thrift/pom.xml b/apache-thrift/pom.xml
index b22364cb19..ab54fc2cef 100644
--- a/apache-thrift/pom.xml
+++ b/apache-thrift/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldungapache-thrift0.0.1-SNAPSHOT
+ apache-thriftpom
diff --git a/apache-tika/pom.xml b/apache-tika/pom.xml
index 5a76fdeeda..0399914a5f 100644
--- a/apache-tika/pom.xml
+++ b/apache-tika/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldungapache-tika0.0.1-SNAPSHOT
-
+ apache-tika
+
com.baeldungparent-modules
diff --git a/apache-zookeeper/pom.xml b/apache-zookeeper/pom.xml
index 0b29186ccc..53e4217358 100644
--- a/apache-zookeeper/pom.xml
+++ b/apache-zookeeper/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldungapache-zookeeper0.0.1-SNAPSHOT
+ apache-zookeeperjar
diff --git a/asm/pom.xml b/asm/pom.xml
index 5aad2a0e37..e56438c808 100644
--- a/asm/pom.xml
+++ b/asm/pom.xml
@@ -5,6 +5,7 @@
com.baeldung.examplesasm1.0
+ asmjar
diff --git a/atomix/pom.xml b/atomix/pom.xml
index f85d2d7484..e50c1d867f 100644
--- a/atomix/pom.xml
+++ b/atomix/pom.xml
@@ -4,7 +4,8 @@
com.atomix.ioatomix0.0.1-SNAPSHOT
-
+ atomix
+
com.baeldungparent-modules
diff --git a/axon/pom.xml b/axon/pom.xml
index 915a04feb5..c643ea9e57 100644
--- a/axon/pom.xml
+++ b/axon/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0axon
-
+ axon
+
parent-modulescom.baeldung
diff --git a/cas/cas-server/pom.xml b/cas/cas-server/pom.xml
index 9b61aaec3d..98f5f10493 100644
--- a/cas/cas-server/pom.xml
+++ b/cas/cas-server/pom.xml
@@ -3,8 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">
4.0.0cas-server
- war1.0
+ cas-server
+ warparent-boot-1
diff --git a/cdi/README.md b/cdi/README.md
index 0477ce85bd..bfb635be9e 100644
--- a/cdi/README.md
+++ b/cdi/README.md
@@ -1,3 +1,5 @@
### Relevant Articles:
- [CDI Interceptor vs Spring AspectJ](http://www.baeldung.com/cdi-interceptor-vs-spring-aspectj)
- [An Introduction to CDI (Contexts and Dependency Injection) in Java](http://www.baeldung.com/java-ee-cdi)
+- [Introduction to the Event Notification Model in CDI 2.0](https://www.baeldung.com/cdi-event-notification)
+
diff --git a/cdi/pom.xml b/cdi/pom.xml
index 2c719c1d7f..0cf5062ccc 100644
--- a/cdi/pom.xml
+++ b/cdi/pom.xml
@@ -2,10 +2,10 @@
4.0.0
- com.baeldungcdi1.0-SNAPSHOT
-
+ cdi
+
com.baeldungparent-spring-4
@@ -14,6 +14,16 @@
+
+ javax.enterprise
+ cdi-api
+ ${cdi-api.version}
+
+
+ org.jboss.weld.se
+ weld-se-core
+ ${weld-se-core.version}
+ org.hamcresthamcrest-core
@@ -42,11 +52,6 @@
aspectjweaver${aspectjweaver.version}
-
- org.jboss.weld.se
- weld-se-core
- ${weld-se-core.version}
- org.springframeworkspring-test
@@ -54,13 +59,13 @@
test
-
- 1.8.9
- 2.4.1.Final
+ 2.0.SP1
+ 3.0.5.Final
+ 1.9.21.33.10.04.12
+ 5.1.2.RELEASE
-
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java b/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java
new file mode 100644
index 0000000000..4896408502
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java
@@ -0,0 +1,15 @@
+package com.baeldung.cdi.cdi2observers.application;
+
+import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.se.SeContainerInitializer;
+
+public class BootstrappingApplication {
+
+ public static void main(String... args) {
+ SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance();
+ try (SeContainer container = containerInitializer.initialize()) {
+ container.getBeanManager().fireEvent(new ExampleEvent("Welcome to Baeldung!"));
+ }
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java
new file mode 100644
index 0000000000..a2329d2ef1
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java
@@ -0,0 +1,14 @@
+package com.baeldung.cdi.cdi2observers.events;
+
+public class ExampleEvent {
+
+ private final String eventMessage;
+
+ public ExampleEvent(String eventMessage) {
+ this.eventMessage = eventMessage;
+ }
+
+ public String getEventMessage() {
+ return eventMessage;
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java
new file mode 100644
index 0000000000..f37030778a
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java
@@ -0,0 +1,14 @@
+package com.baeldung.cdi.cdi2observers.events;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+public class ExampleEventSource {
+
+ @Inject
+ Event exampleEvent;
+
+ public void fireEvent() {
+ exampleEvent.fireAsync(new ExampleEvent("Welcome to Baeldung!"));
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java b/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java
new file mode 100644
index 0000000000..34520c2b3d
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java
@@ -0,0 +1,12 @@
+package com.baeldung.cdi.cdi2observers.observers;
+
+import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
+import javax.annotation.Priority;
+import javax.enterprise.event.Observes;
+
+public class AnotherExampleEventObserver {
+
+ public String onEvent(@Observes @Priority(2) ExampleEvent event) {
+ return event.getEventMessage();
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java b/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java
new file mode 100644
index 0000000000..b3522b2ad0
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java
@@ -0,0 +1,13 @@
+package com.baeldung.cdi.cdi2observers.observers;
+
+import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
+import com.baeldung.cdi.cdi2observers.services.TextService;
+import javax.annotation.Priority;
+import javax.enterprise.event.Observes;
+
+public class ExampleEventObserver {
+
+ public String onEvent(@Observes @Priority(1) ExampleEvent event, TextService textService) {
+ return textService.parseText(event.getEventMessage());
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java b/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java
new file mode 100644
index 0000000000..47788a0657
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java
@@ -0,0 +1,8 @@
+package com.baeldung.cdi.cdi2observers.services;
+
+public class TextService {
+
+ public String parseText(String text) {
+ return text.toUpperCase();
+ }
+}
diff --git a/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java b/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java
new file mode 100644
index 0000000000..deecf13f9a
--- /dev/null
+++ b/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java
@@ -0,0 +1,14 @@
+package com.baeldung.cdi.cdi2observers.tests;
+
+import com.baeldung.cdi.cdi2observers.services.TextService;
+import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.Test;
+
+public class TextServiceUnitTest {
+
+ @Test
+ public void givenTextServiceInstance_whenCalledparseText_thenCorrect() {
+ TextService textService = new TextService();
+ assertThat(textService.parseText("Baeldung")).isEqualTo("BAELDUNG");
+ }
+}
diff --git a/core-groovy/pom.xml b/core-groovy/pom.xml
index 909250710e..e54c766280 100644
--- a/core-groovy/pom.xml
+++ b/core-groovy/pom.xml
@@ -4,6 +4,7 @@
4.0.0core-groovy1.0-SNAPSHOT
+ core-groovyjar
diff --git a/core-java-10/README.md b/core-java-10/README.md
index 84fa381a26..f0a25712a7 100644
--- a/core-java-10/README.md
+++ b/core-java-10/README.md
@@ -4,3 +4,4 @@
- [Java 10 LocalVariable Type-Inference](http://www.baeldung.com/java-10-local-variable-type-inference)
- [Guide to Java 10](http://www.baeldung.com/java-10-overview)
- [Copy a List to Another List in Java](http://www.baeldung.com/java-copy-list-to-another)
+- [Deep Dive Into the New Java JIT Compiler – Graal](https://www.baeldung.com/graal-java-jit-compiler)
diff --git a/core-java-11/README.md b/core-java-11/README.md
new file mode 100644
index 0000000000..181ada3f45
--- /dev/null
+++ b/core-java-11/README.md
@@ -0,0 +1,5 @@
+### Relevant articles
+
+- [Java 11 Single File Source Code](https://www.baeldung.com/java-single-file-source-code)
+- [Java 11 Local Variable Syntax for Lambda Parameters](https://www.baeldung.com/java-var-lambda-params)
+
diff --git a/core-java-11/src/main/java/com/baeldung/Outer.java b/core-java-11/src/main/java/com/baeldung/Outer.java
new file mode 100644
index 0000000000..1d3cd72b44
--- /dev/null
+++ b/core-java-11/src/main/java/com/baeldung/Outer.java
@@ -0,0 +1,24 @@
+package com.baeldung;
+
+import java.lang.reflect.Method;
+
+public class Outer {
+
+ public void outerPublic() {
+ }
+
+ private void outerPrivate() {
+ }
+
+ class Inner {
+
+ public void innerPublic() {
+ outerPrivate();
+ }
+
+ public void innerPublicReflection(Outer ob) throws Exception {
+ Method method = ob.getClass().getDeclaredMethod("outerPrivate");
+ method.invoke(ob);
+ }
+ }
+}
\ No newline at end of file
diff --git a/core-java-11/src/main/java/com/baeldung/add b/core-java-11/src/main/java/com/baeldung/add
new file mode 100755
index 0000000000..539c1a43d4
--- /dev/null
+++ b/core-java-11/src/main/java/com/baeldung/add
@@ -0,0 +1,12 @@
+#!/usr/local/bin/java --source 11
+
+import java.util.Arrays;
+
+public class Addition
+{
+ public static void main(String[] args) {
+ System.out.println(Arrays.stream(args)
+ .mapToInt(Integer::parseInt)
+ .sum());
+ }
+}
\ No newline at end of file
diff --git a/core-java-11/src/test/java/com/baeldung/NewStringAPIUnitTest.java b/core-java-11/src/test/java/com/baeldung/NewStringAPIUnitTest.java
new file mode 100644
index 0000000000..43e9022a64
--- /dev/null
+++ b/core-java-11/src/test/java/com/baeldung/NewStringAPIUnitTest.java
@@ -0,0 +1,43 @@
+package com.baeldung;
+
+import static org.hamcrest.CoreMatchers.is;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class NewStringAPIUnitTest {
+
+ @Test
+ public void whenRepeatStringTwice_thenGetStringTwice() {
+ String output = "La ".repeat(2) + "Land";
+
+ is(output).equals("La La Land");
+ }
+
+ @Test
+ public void whenStripString_thenReturnStringWithoutWhitespaces() {
+ is("\n\t hello \u2005".strip()).equals("hello");
+ }
+
+ @Test
+ public void whenTrimAdvanceString_thenReturnStringWithWhitespaces() {
+ is("\n\t hello \u2005".trim()).equals("hello \u2005");
+ }
+
+ @Test
+ public void whenBlankString_thenReturnTrue() {
+ assertTrue("\n\t\u2005 ".isBlank());
+ }
+
+ @Test
+ public void whenMultilineString_thenReturnNonEmptyLineCount() {
+ String multilineStr = "This is\n \n a multiline\n string.";
+
+ long lineCount = multilineStr.lines()
+ .filter(String::isBlank)
+ .count();
+
+ is(lineCount).equals(3L);
+ }
+}
\ No newline at end of file
diff --git a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java
new file mode 100644
index 0000000000..9e6bd72680
--- /dev/null
+++ b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java
@@ -0,0 +1,46 @@
+package com.baeldung;
+
+import static org.junit.Assert.assertTrue;
+import static org.hamcrest.CoreMatchers.is;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.junit.Test;
+
+public class OuterUnitTest {
+
+ private static final String NEST_HOST_NAME = "com.baeldung.Outer";
+
+ @Test
+ public void whenGetNestHostFromOuter_thenGetNestHost() {
+ is(Outer.class.getNestHost().getName()).equals(NEST_HOST_NAME);
+ }
+
+ @Test
+ public void whenGetNestHostFromInner_thenGetNestHost() {
+ is(Outer.Inner.class.getNestHost().getName()).equals(NEST_HOST_NAME);
+ }
+
+ @Test
+ public void whenCheckNestmatesForNestedClasses_thenGetTrue() {
+ is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(true);
+ }
+
+ @Test
+ public void whenCheckNestmatesForUnrelatedClasses_thenGetFalse() {
+ is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(false);
+ }
+
+ @Test
+ public void whenGetNestMembersForNestedClasses_thenGetAllNestedClasses() {
+ Set nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers())
+ .map(Class::getName)
+ .collect(Collectors.toSet());
+
+ is(nestMembers.size()).equals(2);
+
+ assertTrue(nestMembers.contains("com.baeldung.Outer"));
+ assertTrue(nestMembers.contains("com.baeldung.Outer$Inner"));
+ }
+}
\ No newline at end of file
diff --git a/core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java b/core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java
new file mode 100644
index 0000000000..281155138d
--- /dev/null
+++ b/core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java
@@ -0,0 +1,23 @@
+package com.baeldung.optional;
+
+import org.junit.Test;
+
+import java.util.Optional;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit tests for {@link Optional} in Java 11.
+ */
+public class OptionalUnitTest {
+
+ @Test
+ public void givenAnEmptyOptional_isEmpty_thenBehavesAsExpected() {
+ Optional opt = Optional.of("Baeldung");
+ assertFalse(opt.isEmpty());
+
+ opt = Optional.ofNullable(null);
+ assertTrue(opt.isEmpty());
+ }
+}
diff --git a/core-java-8/README.md b/core-java-8/README.md
index ffd629a170..f9af585ab3 100644
--- a/core-java-8/README.md
+++ b/core-java-8/README.md
@@ -15,7 +15,6 @@
- [Guide to Java 8 Comparator.comparing()](http://www.baeldung.com/java-8-comparator-comparing)
- [Guide To Java 8 Optional](http://www.baeldung.com/java-optional)
- [Guide to the Java 8 forEach](http://www.baeldung.com/foreach-java)
-- [Java Base64 Encoding and Decoding](http://www.baeldung.com/java-base64-encode-and-decode)
- [The Difference Between map() and flatMap()](http://www.baeldung.com/java-difference-map-and-flatmap)
- [Static and Default Methods in Interfaces in Java](http://www.baeldung.com/java-static-default-methods)
- [Efficient Word Frequency Calculator in Java](http://www.baeldung.com/java-word-frequency)
@@ -33,3 +32,8 @@
- [An Overview of Regular Expressions Performance in Java](https://www.baeldung.com/java-regex-performance)
- [Java Primitives versus Objects](https://www.baeldung.com/java-primitives-vs-objects)
- [How to Use if/else Logic in Java 8 Streams](https://www.baeldung.com/java-8-streams-if-else-logic)
+- [How to Replace Many if Statements in Java](https://www.baeldung.com/java-replace-if-statements)
+- [Java @Override Annotation](https://www.baeldung.com/java-override)
+- [Java @SuppressWarnings Annotation](https://www.baeldung.com/java-suppresswarnings)
+- [Java @SafeVarargs Annotation](https://www.baeldung.com/java-safevarargs)
+- [Java @Deprecated Annotation](https://www.baeldung.com/java-deprecated)
diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml
index 18bdaa15f4..112e8b764d 100644
--- a/core-java-8/pom.xml
+++ b/core-java-8/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0com.baeldungcore-java-8
@@ -104,6 +104,24 @@
aspectjweaver${asspectj.version}
+
+ org.powermock
+ powermock-module-junit4
+ ${powermock.version}
+ test
+
+
+ org.powermock
+ powermock-api-mockito2
+ ${powermock.version}
+ test
+
+
+ org.jmockit
+ jmockit
+ ${jmockit.version}
+ test
+
@@ -119,7 +137,7 @@
org.apache.maven.pluginsmaven-compiler-plugin
- 3.1
+ ${maven-compiler-plugin.version}1.8
@@ -142,6 +160,16 @@
+
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
+
+ true
+
+
@@ -159,9 +187,14 @@
3.6.11.8.9
+ 2.0.0-RC.4
+ 1.441.7.01.191.192.0.4.RELEASE
+
+ 3.8.0
+ 2.22.1
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Electronic.java b/core-java-8/src/main/java/com/baeldung/interfaces/Electronic.java
new file mode 100644
index 0000000000..bfbc381483
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/Electronic.java
@@ -0,0 +1,22 @@
+package com.baeldung.interfaces;
+
+public interface Electronic {
+ //Constant variable
+ public static final String LED = "LED";
+
+ //Abstract method
+ public int getElectricityUse();
+
+ // Static method
+ public static boolean isEnergyEfficient(String electtronicType) {
+ if (electtronicType.equals(LED)) {
+ return true;
+ }
+ return false;
+ }
+
+ //Default method
+ public default void printDescription() {
+ System.out.println("Electronic Description");
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Employee.java b/core-java-8/src/main/java/com/baeldung/interfaces/Employee.java
new file mode 100644
index 0000000000..903bc81e6f
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/Employee.java
@@ -0,0 +1,15 @@
+package com.baeldung.interfaces;
+
+public class Employee {
+
+ private double salary;
+
+ public double getSalary() {
+ return salary;
+ }
+
+ public void setSalary(double salary) {
+ this.salary = salary;
+ }
+
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java b/core-java-8/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java
new file mode 100644
index 0000000000..cfa4226c1a
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java
@@ -0,0 +1,18 @@
+package com.baeldung.interfaces;
+
+import java.util.Comparator;
+
+public class EmployeeSalaryComparator implements Comparator {
+
+ @Override
+ public int compare(Employee employeeA, Employee employeeB) {
+
+ if(employeeA.getSalary() < employeeB.getSalary()){
+ return -1;
+ }else if(employeeA.getSalary() > employeeB.getSalary()){
+ return 1;
+ }else{
+ return 0;
+ }
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/HasColor.java b/core-java-8/src/main/java/com/baeldung/interfaces/HasColor.java
new file mode 100644
index 0000000000..6eface2d47
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/HasColor.java
@@ -0,0 +1,5 @@
+package com.baeldung.interfaces;
+
+public interface HasColor {
+ public String getColor();
+}
\ No newline at end of file
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Motorcycle.java b/core-java-8/src/main/java/com/baeldung/interfaces/Motorcycle.java
new file mode 100644
index 0000000000..6003f476a3
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/Motorcycle.java
@@ -0,0 +1,10 @@
+package com.baeldung.interfaces;
+
+import com.baeldung.interfaces.multiinheritance.Transform;
+
+public class Motorcycle implements Transform {
+ @Override
+ public void transform() {
+ // Implementation
+ }
+}
\ No newline at end of file
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Truck.java b/core-java-8/src/main/java/com/baeldung/interfaces/Truck.java
new file mode 100644
index 0000000000..d78de23371
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/Truck.java
@@ -0,0 +1,8 @@
+package com.baeldung.interfaces;
+
+public class Truck extends Vehicle {
+ @Override
+ public void transform() {
+ // implementation
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Vehicle.java b/core-java-8/src/main/java/com/baeldung/interfaces/Vehicle.java
new file mode 100644
index 0000000000..8b4662e1a3
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/Vehicle.java
@@ -0,0 +1,6 @@
+package com.baeldung.interfaces;
+
+import com.baeldung.interfaces.multiinheritance.Transform;
+
+public abstract class Vehicle implements Transform {
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java
new file mode 100644
index 0000000000..b951fc0273
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java
@@ -0,0 +1,13 @@
+package com.baeldung.interfaces.multiinheritance;
+
+public class Car implements Fly, Transform {
+ @Override
+ public void fly() {
+ System.out.println("I can Fly!!");
+ }
+
+ @Override
+ public void transform() {
+ System.out.println("I can Transform!!");
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java
new file mode 100644
index 0000000000..d84182aec6
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java
@@ -0,0 +1,5 @@
+package com.baeldung.interfaces.multiinheritance;
+
+public abstract interface Fly{
+ void fly();
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java
new file mode 100644
index 0000000000..8bdba43a05
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java
@@ -0,0 +1,10 @@
+package com.baeldung.interfaces.multiinheritance;
+
+public interface Transform {
+
+ void transform();
+
+ default void printSpecs(){
+ System.out.println("Transform Specification");
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java
new file mode 100644
index 0000000000..fb0d36e3e0
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java
@@ -0,0 +1,13 @@
+package com.baeldung.interfaces.multiinheritance;
+
+public class Vehicle implements Fly, Transform {
+ @Override
+ public void fly() {
+ System.out.println("I can Fly!!");
+ }
+
+ @Override
+ public void transform() {
+ System.out.println("I can Transform!!");
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java
new file mode 100644
index 0000000000..afb3142d96
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java
@@ -0,0 +1,25 @@
+package com.baeldung.interfaces.polymorphysim;
+
+public class Circle implements Shape {
+
+ private double radius;
+
+ public Circle(double radius){
+ this.radius = radius;
+ }
+
+ @Override
+ public String name() {
+ return "Circle";
+ }
+
+ @Override
+ public double area() {
+ return Math.PI * (radius * radius);
+ }
+
+ @Override
+ public String getColor() {
+ return "green";
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/DisplayShape.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/DisplayShape.java
new file mode 100644
index 0000000000..d9c9dd107a
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/DisplayShape.java
@@ -0,0 +1,26 @@
+package com.baeldung.interfaces.polymorphysim;
+
+import java.util.ArrayList;
+
+public class DisplayShape {
+
+ private ArrayList shapes;
+
+ public ArrayList getShapes() {
+ return shapes;
+ }
+
+ public DisplayShape() {
+ shapes = new ArrayList<>();
+ }
+
+ public void add(Shape shape) {
+ shapes.add(shape);
+ }
+
+ public void display() {
+ for (Shape shape : shapes) {
+ System.out.println(shape.name() + " area: " + shape.area());
+ }
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/FunctionalMain.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/FunctionalMain.java
new file mode 100644
index 0000000000..5316dd7db7
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/FunctionalMain.java
@@ -0,0 +1,23 @@
+package com.baeldung.interfaces.polymorphysim;
+
+import java.util.function.Predicate;
+
+public class FunctionalMain {
+
+public static void main(String[] args) {
+ Shape circleShape = new Circle(2);
+ Shape squareShape = new Square(2);
+
+ DisplayShape DisplayShape = new DisplayShape();
+ DisplayShape.add(circleShape);
+ DisplayShape.add(squareShape);
+
+ Predicate checkArea = (shape) -> shape.area() < 5;
+
+ for (Shape shape : DisplayShape.getShapes()) {
+ if (checkArea.test(shape)) {
+ System.out.println(shape.name() + " " + shape.area());
+ }
+ }
+}
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/MainPolymorphic.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/MainPolymorphic.java
new file mode 100644
index 0000000000..cc43c1300b
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/MainPolymorphic.java
@@ -0,0 +1,15 @@
+package com.baeldung.interfaces.polymorphysim;
+
+public class MainPolymorphic {
+ public static void main(String[] args){
+
+ Shape circleShape = new Circle(2);
+ Shape squareShape = new Square(2);
+
+ DisplayShape displayShape = new DisplayShape();
+ displayShape.add(circleShape);
+ displayShape.add(squareShape);
+
+ displayShape.display();
+ }
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java
new file mode 100644
index 0000000000..560e07a80a
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java
@@ -0,0 +1,9 @@
+package com.baeldung.interfaces.polymorphysim;
+
+import com.baeldung.interfaces.HasColor;
+
+public interface Shape extends HasColor {
+
+ public abstract String name();
+ public abstract double area();
+}
diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java
new file mode 100644
index 0000000000..00b75ace20
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java
@@ -0,0 +1,25 @@
+package com.baeldung.interfaces.polymorphysim;
+
+public class Square implements Shape {
+
+ private double width;
+
+ public Square(double width) {
+ this.width = width;
+ }
+
+ @Override
+ public String name() {
+ return "Square";
+ }
+
+ @Override
+ public double area() {
+ return width * width;
+ }
+
+ @Override
+ public String getColor() {
+ return "red";
+ }
+}
diff --git a/core-java-8/src/test/java/com/baeldung/interfaces/PolymorphysimUnitTest.java b/core-java-8/src/test/java/com/baeldung/interfaces/PolymorphysimUnitTest.java
new file mode 100644
index 0000000000..7ded5e6621
--- /dev/null
+++ b/core-java-8/src/test/java/com/baeldung/interfaces/PolymorphysimUnitTest.java
@@ -0,0 +1,26 @@
+package com.baeldung.interfaces;
+
+import com.baeldung.interfaces.polymorphysim.Circle;
+import com.baeldung.interfaces.polymorphysim.Shape;
+import com.baeldung.interfaces.polymorphysim.Square;
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+
+public class PolymorphysimUnitTest {
+
+ @Test
+ public void whenInterfacePointsToCircle_CircleAreaMethodisBeingCalled(){
+ double expectedArea = 12.566370614359172;
+ Shape circle = new Circle(2);
+ double actualArea = circle.area();
+ Assertions.assertThat(actualArea).isEqualTo(expectedArea);
+ }
+
+ @Test
+ public void whenInterfacePointsToSquare_SquareAreaMethodisBeingCalled(){
+ double expectedArea = 4;
+ Shape square = new Square(2);
+ double actualArea = square.area();
+ Assertions.assertThat(actualArea).isEqualTo(expectedArea);
+ }
+}
diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java
new file mode 100644
index 0000000000..fa579f9a00
--- /dev/null
+++ b/core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java
@@ -0,0 +1,131 @@
+package com.baeldung.java8;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import org.junit.Test;
+
+public class Java8PredicateChainUnitTest {
+
+ private List names = Arrays.asList("Adam", "Alexander", "John", "Tom");
+
+ @Test
+ public void whenFilterList_thenSuccess() {
+ List result = names.stream()
+ .filter(name -> name.startsWith("A"))
+ .collect(Collectors.toList());
+
+ assertEquals(2, result.size());
+ assertThat(result, contains("Adam", "Alexander"));
+ }
+
+ @Test
+ public void whenFilterListWithMultipleFilters_thenSuccess() {
+ List result = names.stream()
+ .filter(name -> name.startsWith("A"))
+ .filter(name -> name.length() < 5)
+ .collect(Collectors.toList());
+
+ assertEquals(1, result.size());
+ assertThat(result, contains("Adam"));
+ }
+
+ @Test
+ public void whenFilterListWithComplexPredicate_thenSuccess() {
+ List result = names.stream()
+ .filter(name -> name.startsWith("A") && name.length() < 5)
+ .collect(Collectors.toList());
+
+ assertEquals(1, result.size());
+ assertThat(result, contains("Adam"));
+ }
+
+ @Test
+ public void whenFilterListWithCombinedPredicatesInline_thenSuccess() {
+ List result = names.stream()
+ .filter(((Predicate) name -> name.startsWith("A")).and(name -> name.length() < 5))
+ .collect(Collectors.toList());
+
+ assertEquals(1, result.size());
+ assertThat(result, contains("Adam"));
+ }
+
+ @Test
+ public void whenFilterListWithCombinedPredicatesUsingAnd_thenSuccess() {
+ Predicate predicate1 = str -> str.startsWith("A");
+ Predicate predicate2 = str -> str.length() < 5;
+
+ List result = names.stream()
+ .filter(predicate1.and(predicate2))
+ .collect(Collectors.toList());
+
+ assertEquals(1, result.size());
+ assertThat(result, contains("Adam"));
+ }
+
+ @Test
+ public void whenFilterListWithCombinedPredicatesUsingOr_thenSuccess() {
+ Predicate predicate1 = str -> str.startsWith("J");
+ Predicate predicate2 = str -> str.length() < 4;
+
+ List result = names.stream()
+ .filter(predicate1.or(predicate2))
+ .collect(Collectors.toList());
+
+ assertEquals(2, result.size());
+ assertThat(result, contains("John", "Tom"));
+ }
+
+ @Test
+ public void whenFilterListWithCombinedPredicatesUsingOrAndNegate_thenSuccess() {
+ Predicate predicate1 = str -> str.startsWith("J");
+ Predicate predicate2 = str -> str.length() < 4;
+
+ List result = names.stream()
+ .filter(predicate1.or(predicate2.negate()))
+ .collect(Collectors.toList());
+
+ assertEquals(3, result.size());
+ assertThat(result, contains("Adam", "Alexander", "John"));
+ }
+
+ @Test
+ public void whenFilterListWithCollectionOfPredicatesUsingAnd_thenSuccess() {
+ List> allPredicates = new ArrayList>();
+ allPredicates.add(str -> str.startsWith("A"));
+ allPredicates.add(str -> str.contains("d"));
+ allPredicates.add(str -> str.length() > 4);
+
+ List result = names.stream()
+ .filter(allPredicates.stream()
+ .reduce(x -> true, Predicate::and))
+ .collect(Collectors.toList());
+
+ assertEquals(1, result.size());
+ assertThat(result, contains("Alexander"));
+ }
+
+ @Test
+ public void whenFilterListWithCollectionOfPredicatesUsingOr_thenSuccess() {
+ List> allPredicates = new ArrayList>();
+ allPredicates.add(str -> str.startsWith("A"));
+ allPredicates.add(str -> str.contains("d"));
+ allPredicates.add(str -> str.length() > 4);
+
+ List result = names.stream()
+ .filter(allPredicates.stream()
+ .reduce(x -> false, Predicate::or))
+ .collect(Collectors.toList());
+
+ assertEquals(2, result.size());
+ assertThat(result, contains("Adam", "Alexander"));
+ }
+
+}
diff --git a/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java
new file mode 100644
index 0000000000..04c1a0b74e
--- /dev/null
+++ b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java
@@ -0,0 +1,43 @@
+package com.baeldung.time;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ LocalDateTime.class })
+public class LocalDateTimeUnitTest {
+
+ @Test
+ public void givenLocalDateTimeMock_whenNow_thenGetFixedLocalDateTime() {
+ Clock clock = Clock.fixed(Instant.parse("2014-12-22T10:15:30.00Z"), ZoneId.of("UTC"));
+ LocalDateTime dateTime = LocalDateTime.now(clock);
+ mockStatic(LocalDateTime.class);
+ when(LocalDateTime.now()).thenReturn(dateTime);
+ String dateTimeExpected = "2014-12-22T10:15:30";
+
+ LocalDateTime now = LocalDateTime.now();
+
+ assertThat(now).isEqualTo(dateTimeExpected);
+ }
+
+ @Test
+ public void givenFixedClock_whenNow_thenGetFixedLocalDateTime() {
+ Clock clock = Clock.fixed(Instant.parse("2014-12-22T10:15:30.00Z"), ZoneId.of("UTC"));
+ String dateTimeExpected = "2014-12-22T10:15:30";
+
+ LocalDateTime dateTime = LocalDateTime.now(clock);
+
+ assertThat(dateTime).isEqualTo(dateTimeExpected);
+ }
+}
diff --git a/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java
new file mode 100644
index 0000000000..13861dfd0b
--- /dev/null
+++ b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java
@@ -0,0 +1,48 @@
+package com.baeldung.time;
+
+import mockit.Expectations;
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.jupiter.api.Test;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class LocalDateTimeWithJMockUnitTest {
+
+ @Test
+ public void givenLocalDateTimeWithJMock_whenNow_thenGetFixedLocalDateTime() {
+ Clock clock = Clock.fixed(Instant.parse("2014-12-21T10:15:30.00Z"), ZoneId.of("UTC"));
+ new MockUp() {
+ @Mock
+ public LocalDateTime now() {
+ return LocalDateTime.now(clock);
+ }
+ };
+ String dateTimeExpected = "2014-12-21T10:15:30";
+
+ LocalDateTime now = LocalDateTime.now();
+
+ assertThat(now).isEqualTo(dateTimeExpected);
+ }
+
+ @Test
+ public void givenLocalDateTimeWithExpectations_whenNow_thenGetFixedLocalDateTime() {
+ Clock clock = Clock.fixed(Instant.parse("2014-12-23T10:15:30.00Z"), ZoneId.of("UTC"));
+ LocalDateTime dateTimeExpected = LocalDateTime.now(clock);
+ new Expectations(LocalDateTime.class) {
+ {
+ LocalDateTime.now();
+ result = dateTimeExpected;
+ }
+ };
+
+ LocalDateTime now = LocalDateTime.now();
+
+ assertThat(now).isEqualTo(dateTimeExpected);
+ }
+}
diff --git a/core-java-9/README.md b/core-java-9/README.md
index 38816471aa..c96267dc95 100644
--- a/core-java-9/README.md
+++ b/core-java-9/README.md
@@ -9,7 +9,6 @@
- [Java 9 Convenience Factory Methods for Collections](http://www.baeldung.com/java-9-collections-factory-methods)
- [New Stream Collectors in Java 9](http://www.baeldung.com/java9-stream-collectors)
- [Java 9 CompletableFuture API Improvements](http://www.baeldung.com/java-9-completablefuture)
-- [Spring Security – Redirect to the Previous URL After Login](http://www.baeldung.com/spring-security-redirect-login)
- [Java 9 Process API Improvements](http://www.baeldung.com/java-9-process-api)
- [Introduction to Java 9 StackWalking API](http://www.baeldung.com/java-9-stackwalking-api)
- [Introduction to Project Jigsaw](http://www.baeldung.com/project-jigsaw-java-modularity)
diff --git a/core-java-9/pom.xml b/core-java-9/pom.xml
index f22d0a3ed9..cd1fa74dbb 100644
--- a/core-java-9/pom.xml
+++ b/core-java-9/pom.xml
@@ -1,7 +1,6 @@
4.0.0
- com.baeldungcore-java-90.2-SNAPSHOTcore-java-9
diff --git a/core-java-arrays/README.md b/core-java-arrays/README.md
index bda2cf90bf..56110585ac 100644
--- a/core-java-arrays/README.md
+++ b/core-java-arrays/README.md
@@ -12,4 +12,4 @@
- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide)
- [How to Invert an Array in Java](http://www.baeldung.com/java-invert-array)
- [Array Operations in Java](http://www.baeldung.com/java-common-array-operations)
-
+- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection)
diff --git a/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java b/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java
index 757a8f8ec1..a7592574d9 100644
--- a/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java
+++ b/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java
@@ -7,6 +7,14 @@ public class Employee implements Serializable {
private int id;
private String name;
+ public Employee() {
+ }
+
+ public Employee(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
public int getId() {
return id;
}
diff --git a/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java b/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java
new file mode 100644
index 0000000000..59035738fe
--- /dev/null
+++ b/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java
@@ -0,0 +1,90 @@
+package com.baeldung.sort;
+
+import com.baeldung.arraycopy.model.Employee;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.stream.IntStream;
+
+import static org.junit.Assert.assertArrayEquals;
+
+public class ArraySortUnitTest {
+ private Employee[] employees;
+ private int[] numbers;
+ private String[] strings;
+
+ private Employee john = new Employee(6, "John");
+ private Employee mary = new Employee(3, "Mary");
+ private Employee david = new Employee(4, "David");
+
+ @Before
+ public void setup() {
+ createEmployeesArray();
+ createNumbersArray();
+ createStringArray();
+ }
+
+ private void createEmployeesArray() {
+ employees = new Employee[]{john, mary, david};
+ }
+
+ private void createNumbersArray() {
+ numbers = new int[]{-8, 7, 5, 9, 10, -2, 3};
+ }
+
+ private void createStringArray() {
+ strings = new String[]{"learning", "java", "with", "baeldung"};
+ }
+
+ @Test
+ public void givenIntArray_whenSortingAscending_thenCorrectlySorted() {
+ Arrays.sort(numbers);
+
+ assertArrayEquals(new int[]{-8, -2, 3, 5, 7, 9, 10}, numbers);
+ }
+
+ @Test
+ public void givenIntArray_whenSortingDescending_thenCorrectlySorted() {
+ numbers = IntStream.of(numbers).boxed().sorted(Comparator.reverseOrder()).mapToInt(i -> i).toArray();
+
+ assertArrayEquals(new int[]{10, 9, 7, 5, 3, -2, -8}, numbers);
+ }
+
+ @Test
+ public void givenStringArray_whenSortingAscending_thenCorrectlySorted() {
+ Arrays.sort(strings);
+
+ assertArrayEquals(new String[]{"baeldung", "java", "learning", "with"}, strings);
+ }
+
+ @Test
+ public void givenStringArray_whenSortingDescending_thenCorrectlySorted() {
+ Arrays.sort(strings, Comparator.reverseOrder());
+
+ assertArrayEquals(new String[]{"with", "learning", "java", "baeldung"}, strings);
+ }
+
+ @Test
+ public void givenObjectArray_whenSortingAscending_thenCorrectlySorted() {
+ Arrays.sort(employees, Comparator.comparing(Employee::getName));
+
+ assertArrayEquals(new Employee[]{david, john, mary}, employees);
+ }
+
+ @Test
+ public void givenObjectArray_whenSortingDescending_thenCorrectlySorted() {
+ Arrays.sort(employees, Comparator.comparing(Employee::getName).reversed());
+
+ assertArrayEquals(new Employee[]{mary, john, david}, employees);
+ }
+
+ @Test
+ public void givenObjectArray_whenSortingMultipleAttributesAscending_thenCorrectlySorted() {
+ Arrays.sort(employees, Comparator.comparing(Employee::getName).thenComparing(Employee::getId));
+
+ assertArrayEquals(new Employee[]{david, john, mary}, employees);
+ }
+
+}
diff --git a/core-java-collections-list/README.md b/core-java-collections-list/README.md
new file mode 100644
index 0000000000..aba53f5b30
--- /dev/null
+++ b/core-java-collections-list/README.md
@@ -0,0 +1,27 @@
+=========
+
+## Core Java Collections List Cookbooks and Examples
+
+### Relevant Articles:
+- [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list)
+- [Guide to the Java ArrayList](http://www.baeldung.com/java-arraylist)
+- [Random List Element](http://www.baeldung.com/java-random-list-element)
+- [Removing all nulls from a List in Java](http://www.baeldung.com/java-remove-nulls-from-list)
+- [Removing all duplicates from a List in Java](http://www.baeldung.com/java-remove-duplicates-from-list)
+- [How to TDD a List Implementation in Java](http://www.baeldung.com/java-test-driven-list)
+- [Iterating Backward Through a List](http://www.baeldung.com/java-list-iterate-backwards)
+- [Add Multiple Items to an Java ArrayList](http://www.baeldung.com/java-add-items-array-list)
+- [Remove the First Element from a List](http://www.baeldung.com/java-remove-first-element-from-list)
+- [How to Find an Element in a List with Java](http://www.baeldung.com/find-list-element-java)
+- [Copy a List to Another List in Java](http://www.baeldung.com/java-copy-list-to-another)
+- [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max)
+- [Collections.emptyList() vs. New List Instance](https://www.baeldung.com/java-collections-emptylist-new-list)
+- [Remove All Occurrences of a Specific Value from a List](https://www.baeldung.com/java-remove-value-from-list)
+- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality)
+- [Java 8 Streams: Find Items From One List Based On Values From Another List](https://www.baeldung.com/java-streams-find-list-items)
+- [A Guide to the Java LinkedList](http://www.baeldung.com/java-linkedlist)
+- [Java List UnsupportedOperationException](http://www.baeldung.com/java-list-unsupported-operation-exception)
+- [Java List Initialization in One Line](https://www.baeldung.com/java-init-list-one-line)
+- [Ways to Iterate Over a List in Java](https://www.baeldung.com/java-iterate-list)
+- [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist)
+- [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections)
\ No newline at end of file
diff --git a/core-java-collections-list/pom.xml b/core-java-collections-list/pom.xml
new file mode 100644
index 0000000000..ee99e470d0
--- /dev/null
+++ b/core-java-collections-list/pom.xml
@@ -0,0 +1,48 @@
+
+ 4.0.0
+ core-java-collections-list
+ 0.1.0-SNAPSHOT
+ jar
+ core-java-collections-list
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+
+ org.apache.commons
+ commons-collections4
+ ${commons-collections4.version}
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+ test
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+
+
+ 4.1
+ 3.8.1
+ 1.7.0
+ 3.11.1
+ 1.16.12
+
+
diff --git a/core-java-collections/src/main/java/com/baeldung/classcastexception/ClassCastException.java b/core-java-collections-list/src/main/java/com/baeldung/classcastexception/ClassCastException.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/classcastexception/ClassCastException.java
rename to core-java-collections-list/src/main/java/com/baeldung/classcastexception/ClassCastException.java
diff --git a/core-java-collections/src/main/java/com/baeldung/findanelement/Customer.java b/core-java-collections-list/src/main/java/com/baeldung/findanelement/Customer.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/findanelement/Customer.java
rename to core-java-collections-list/src/main/java/com/baeldung/findanelement/Customer.java
diff --git a/core-java-collections/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java b/core-java-collections-list/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java
rename to core-java-collections-list/src/main/java/com/baeldung/findanelement/FindACustomerInGivenList.java
diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/CopyListService.java b/core-java-collections-list/src/main/java/com/baeldung/java/list/CopyListService.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/java/list/CopyListService.java
rename to core-java-collections-list/src/main/java/com/baeldung/java/list/CopyListService.java
diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/CustomList.java b/core-java-collections-list/src/main/java/com/baeldung/java/list/CustomList.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/java/list/CustomList.java
rename to core-java-collections-list/src/main/java/com/baeldung/java/list/CustomList.java
diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/Flower.java b/core-java-collections-list/src/main/java/com/baeldung/java/list/Flower.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/java/list/Flower.java
rename to core-java-collections-list/src/main/java/com/baeldung/java/list/Flower.java
diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/ReverseIterator.java b/core-java-collections-list/src/main/java/com/baeldung/java/list/ReverseIterator.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/java/list/ReverseIterator.java
rename to core-java-collections-list/src/main/java/com/baeldung/java/list/ReverseIterator.java
diff --git a/core-java-collections-list/src/main/java/com/baeldung/java/list/WaysToIterate.java b/core-java-collections-list/src/main/java/com/baeldung/java/list/WaysToIterate.java
new file mode 100644
index 0000000000..3cce08eabb
--- /dev/null
+++ b/core-java-collections-list/src/main/java/com/baeldung/java/list/WaysToIterate.java
@@ -0,0 +1,67 @@
+package com.baeldung.java.list;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * Demonstrates the different ways to loop over
+ * the elements of a list.
+ */
+public class WaysToIterate {
+
+ List countries = Arrays.asList("Germany", "Panama", "Australia");
+
+ /**
+ * Iterate over a list using a basic for loop
+ */
+ public void iterateWithForLoop() {
+ for (int i = 0; i < countries.size(); i++) {
+ System.out.println(countries.get(i));
+ }
+ }
+
+ /**
+ * Iterate over a list using the enhanced for loop
+ */
+ public void iterateWithEnhancedForLoop() {
+ for (String country : countries) {
+ System.out.println(country);
+ }
+ }
+
+ /**
+ * Iterate over a list using an Iterator
+ */
+ public void iterateWithIterator() {
+ Iterator countriesIterator = countries.iterator();
+ while(countriesIterator.hasNext()) {
+ System.out.println(countriesIterator.next());
+ }
+ }
+
+ /**
+ * Iterate over a list using a ListIterator
+ */
+ public void iterateWithListIterator() {
+ ListIterator listIterator = countries.listIterator();
+ while(listIterator.hasNext()) {
+ System.out.println(listIterator.next());
+ }
+ }
+
+ /**
+ * Iterate over a list using the Iterable.forEach() method
+ */
+ public void iterateWithForEach() {
+ countries.forEach(System.out::println);
+ }
+
+ /**
+ * Iterate over a list using the Stream.forEach() method
+ */
+ public void iterateWithStreamForEach() {
+ countries.stream().forEach((c) -> System.out.println(c));
+ }
+}
\ No newline at end of file
diff --git a/core-java-collections/src/main/java/com/baeldung/java_8_features/Car.java b/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Car.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/java_8_features/Car.java
rename to core-java-collections-list/src/main/java/com/baeldung/java_8_features/Car.java
diff --git a/core-java-collections/src/main/java/com/baeldung/java_8_features/Person.java b/core-java-collections-list/src/main/java/com/baeldung/java_8_features/Person.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/java_8_features/Person.java
rename to core-java-collections-list/src/main/java/com/baeldung/java_8_features/Person.java
diff --git a/core-java-8/src/main/java/com/baeldung/list/Flower.java b/core-java-collections-list/src/main/java/com/baeldung/list/Flower.java
similarity index 100%
rename from core-java-8/src/main/java/com/baeldung/list/Flower.java
rename to core-java-collections-list/src/main/java/com/baeldung/list/Flower.java
diff --git a/core-java-collections/src/main/java/com/baeldung/list/listoflist/Pen.java b/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pen.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/list/listoflist/Pen.java
rename to core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pen.java
diff --git a/core-java-collections/src/main/java/com/baeldung/list/listoflist/Pencil.java b/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pencil.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/list/listoflist/Pencil.java
rename to core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Pencil.java
diff --git a/core-java-collections/src/main/java/com/baeldung/list/listoflist/Rubber.java b/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Rubber.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/list/listoflist/Rubber.java
rename to core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Rubber.java
diff --git a/core-java-collections/src/main/java/com/baeldung/list/listoflist/Stationery.java b/core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Stationery.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/list/listoflist/Stationery.java
rename to core-java-collections-list/src/main/java/com/baeldung/list/listoflist/Stationery.java
diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java
new file mode 100644
index 0000000000..e11f8e8ba0
--- /dev/null
+++ b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java
@@ -0,0 +1,36 @@
+package com.baeldung.list.multidimensional;
+
+import java.util.ArrayList;
+
+public class ArrayListOfArrayList {
+
+ public static void main(String args[]) {
+
+ int vertexCount = 3;
+ ArrayList> graph = new ArrayList<>(vertexCount);
+
+ //Initializing each element of ArrayList with ArrayList
+ for(int i = 0; i< vertexCount; i++) {
+ graph.add(new ArrayList());
+ }
+
+ //We can add any number of columns to each row
+ graph.get(0).add(1);
+ graph.get(1).add(2);
+ graph.get(2).add(0);
+ graph.get(1).add(0);
+ graph.get(2).add(1);
+ graph.get(0).add(2);
+
+ vertexCount = graph.size();
+ for(int i = 0; i < vertexCount; i++) {
+ int edgeCount = graph.get(i).size();
+ for(int j = 0; j < edgeCount; j++) {
+ Integer startVertex = i;
+ Integer endVertex = graph.get(i).get(j);
+ System.out.printf("Vertex %d is connected to vertex %d%n", startVertex, endVertex);
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ThreeDimensionalArrayList.java b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ThreeDimensionalArrayList.java
new file mode 100644
index 0000000000..2021afb0ee
--- /dev/null
+++ b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ThreeDimensionalArrayList.java
@@ -0,0 +1,45 @@
+package com.baeldung.list.multidimensional;
+
+import java.util.ArrayList;
+
+public class ThreeDimensionalArrayList {
+
+ public static void main(String args[]) {
+
+ int x_axis_length = 2;
+ int y_axis_length = 2;
+ int z_axis_length = 2;
+ ArrayList< ArrayList< ArrayList > > space = new ArrayList<>(x_axis_length);
+
+ //Initializing each element of ArrayList with ArrayList< ArrayList >
+ for(int i = 0; i < x_axis_length; i++) {
+ space.add(new ArrayList< ArrayList >(y_axis_length));
+ for(int j = 0; j < y_axis_length; j++) {
+ space.get(i).add(new ArrayList(z_axis_length));
+ }
+ }
+
+ //Set Red color for points (0,0,0) and (0,0,1)
+ space.get(0).get(0).add(0,"Red");
+ space.get(0).get(0).add(1,"Red");
+ //Set Blue color for points (0,1,0) and (0,1,1)
+ space.get(0).get(1).add(0,"Blue");
+ space.get(0).get(1).add(1,"Blue");
+ //Set Green color for points (1,0,0) and (1,0,1)
+ space.get(1).get(0).add(0,"Green");
+ space.get(1).get(0).add(1,"Green");
+ //Set Yellow color for points (1,1,0) and (1,1,1)
+ space.get(1).get(1).add(0,"Yellow");
+ space.get(1).get(1).add(1,"Yellow");
+
+ //Printing colors for all the points
+ for(int i = 0; i < x_axis_length; i++) {
+ for(int j = 0; j < y_axis_length; j++) {
+ for(int k = 0; k < z_axis_length; k++) {
+ System.out.println("Color of point ("+i+","+j+","+k+") is :"+space.get(i).get(j).get(k));
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/core-java-collections/src/main/java/com/baeldung/list/removeall/RemoveAll.java b/core-java-collections-list/src/main/java/com/baeldung/list/removeall/RemoveAll.java
similarity index 100%
rename from core-java-collections/src/main/java/com/baeldung/list/removeall/RemoveAll.java
rename to core-java-collections-list/src/main/java/com/baeldung/list/removeall/RemoveAll.java
diff --git a/ethereumj/src/main/resources/logback.xml b/core-java-collections-list/src/main/resources/logback.xml
similarity index 100%
rename from ethereumj/src/main/resources/logback.xml
rename to core-java-collections-list/src/main/resources/logback.xml
diff --git a/core-java-collections/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/array/converter/ArrayConvertToListUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/collection/CollectionsEmpty.java b/core-java-collections-list/src/test/java/com/baeldung/collection/CollectionsEmpty.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/collection/CollectionsEmpty.java
rename to core-java-collections-list/src/test/java/com/baeldung/collection/CollectionsEmpty.java
diff --git a/core-java-collections/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/findItems/FindItemsBasedOnOtherStreamUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/findanelement/FindACustomerInGivenListUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/java/list/CopyListServiceUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/java/list/CustomListUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java/list/CustomListUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/java/list/CustomListUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/java/list/CustomListUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/java/list/ReverseIteratorUnitTest.java
diff --git a/core-java-collections-list/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java
new file mode 100644
index 0000000000..973c60b233
--- /dev/null
+++ b/core-java-collections-list/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java
@@ -0,0 +1,71 @@
+package com.baeldung.java.list;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.junit.Test;
+
+public class WaysToIterateUnitTest {
+
+ List globalCountries = new ArrayList();
+ List europeanCountries = Arrays.asList("Germany", "Panama", "Australia");
+
+ @Test
+ public void whenIteratingUsingForLoop_thenReturnThreeAsSizeOfList() {
+ for (int i = 0; i < europeanCountries.size(); i++) {
+ globalCountries.add(europeanCountries.get(i));
+ }
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingEnhancedForLoop_thenReturnThreeAsSizeOfList() {
+ for (String country : europeanCountries) {
+ globalCountries.add(country);
+ }
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingIterator_thenReturnThreeAsSizeOfList() {
+ Iterator countriesIterator = europeanCountries.iterator();
+ while (countriesIterator.hasNext()) {
+ globalCountries.add(countriesIterator.next());
+ }
+
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingListIterator_thenReturnThreeAsSizeOfList() {
+ ListIterator countriesIterator = europeanCountries.listIterator();
+ while (countriesIterator.hasNext()) {
+ globalCountries.add(countriesIterator.next());
+ }
+
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingForEach_thenReturnThreeAsSizeOfList() {
+ europeanCountries.forEach(country -> globalCountries.add(country));
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingStreamForEach_thenReturnThreeAsSizeOfList() {
+ europeanCountries.stream().forEach((country) -> globalCountries.add(country));
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+}
\ No newline at end of file
diff --git a/core-java-collections/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/java/listInitialization/ListInitializationUnitTest.java
diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java
similarity index 100%
rename from core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java
diff --git a/core-java-8/src/test/java/com/baeldung/list/AddElementsUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java
similarity index 100%
rename from core-java-8/src/test/java/com/baeldung/list/AddElementsUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/list/flattennestedlist/FlattenNestedListUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/list/listoflist/AddElementsToListUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/list/listoflist/ListOfListsUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/list/removeall/RemoveAllUnitTest.java
diff --git a/core-java-collections/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java
rename to core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java
diff --git a/core-java/src/test/java/com/baeldung/RandomListElementUnitTest.java b/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java
similarity index 98%
rename from core-java/src/test/java/com/baeldung/RandomListElementUnitTest.java
rename to core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java
index 6ae7c40f4d..4f5ba0f82f 100644
--- a/core-java/src/test/java/com/baeldung/RandomListElementUnitTest.java
+++ b/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung;
+package org.baeldung;
import com.google.common.collect.Lists;
import org.junit.Test;
diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java b/core-java-collections-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java
rename to core-java-collections-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java
diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java b/core-java-collections-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java
rename to core-java-collections-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java
diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java b/core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java
rename to core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java
diff --git a/core-java-collections/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java b/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java
rename to core-java-collections-list/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java
diff --git a/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListJUnitTest.java b/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListJUnitTest.java
new file mode 100644
index 0000000000..f9c9d3fda8
--- /dev/null
+++ b/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListJUnitTest.java
@@ -0,0 +1,47 @@
+package org.baeldung.java.lists;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+
+import java.util.stream.Collectors;
+
+public class ListJUnitTest {
+
+ private final List list1 = Arrays.asList("1", "2", "3", "4");
+ private final List list2 = Arrays.asList("1", "2", "3", "4");
+ private final List list3 = Arrays.asList("1", "2", "4", "3");
+
+ @Test
+ public void whenTestingForEquality_ShouldBeEqual() throws Exception {
+ Assert.assertEquals(list1, list2);
+ Assert.assertNotSame(list1, list2);
+ Assert.assertNotEquals(list1, list3);
+ }
+
+ @Test
+ public void whenIntersection_ShouldReturnCommonElements() throws Exception {
+ List list = Arrays.asList("red", "blue", "blue", "green", "red");
+ List otherList = Arrays.asList("red", "green", "green", "yellow");
+
+ Set commonElements = new HashSet(Arrays.asList("red", "green"));
+
+ Set result = list.stream()
+ .distinct()
+ .filter(otherList::contains)
+ .collect(Collectors.toSet());
+
+ Assert.assertEquals(commonElements, result);
+
+ Set inverseResult = otherList.stream()
+ .distinct()
+ .filter(list::contains)
+ .collect(Collectors.toSet());
+
+ Assert.assertEquals(commonElements, inverseResult);
+ }
+}
diff --git a/core-java-collections/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java b/core-java-collections-list/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java
similarity index 100%
rename from core-java-collections/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java
rename to core-java-collections-list/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java
diff --git a/core-java-collections/src/test/java/org/baeldung/java/lists/README.md b/core-java-collections-list/src/test/java/org/baeldung/java/lists/README.md
similarity index 100%
rename from core-java-collections/src/test/java/org/baeldung/java/lists/README.md
rename to core-java-collections-list/src/test/java/org/baeldung/java/lists/README.md
diff --git a/core-java-collections/README.md b/core-java-collections/README.md
index 0fcf7367c7..1a90d01a82 100644
--- a/core-java-collections/README.md
+++ b/core-java-collections/README.md
@@ -3,36 +3,21 @@
## Core Java Collections Cookbooks and Examples
### Relevant Articles:
-- [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list)
-- [Guide to the Java ArrayList](http://www.baeldung.com/java-arraylist)
-- [Random List Element](http://www.baeldung.com/java-random-list-element)
- [Java - Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections)
-- [Removing all nulls from a List in Java](http://www.baeldung.com/java-remove-nulls-from-list)
-- [Removing all duplicates from a List in Java](http://www.baeldung.com/java-remove-duplicates-from-list)
-- [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections)
- [HashSet and TreeSet Comparison](http://www.baeldung.com/java-hashset-vs-treeset)
- [Collect a Java Stream to an Immutable Collection](http://www.baeldung.com/java-stream-immutable-collection)
- [Introduction to the Java ArrayDeque](http://www.baeldung.com/java-array-deque)
- [A Guide to HashSet in Java](http://www.baeldung.com/java-hashset)
- [A Guide to TreeSet in Java](http://www.baeldung.com/java-tree-set)
-- [How to TDD a List Implementation in Java](http://www.baeldung.com/java-test-driven-list)
- [Getting the Size of an Iterable in Java](http://www.baeldung.com/java-iterable-size)
-- [Iterating Backward Through a List](http://www.baeldung.com/java-list-iterate-backwards)
- [How to Filter a Collection in Java](http://www.baeldung.com/java-collection-filtering)
-- [Add Multiple Items to an Java ArrayList](http://www.baeldung.com/java-add-items-array-list)
-- [Remove the First Element from a List](http://www.baeldung.com/java-remove-first-element-from-list)
- [Initializing HashSet at the Time of Construction](http://www.baeldung.com/java-initialize-hashset)
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)
- [Fail-Safe Iterator vs Fail-Fast Iterator](http://www.baeldung.com/java-fail-safe-vs-fail-fast-iterator)
- [Shuffling Collections In Java](http://www.baeldung.com/java-shuffle-collection)
-- [How to Find an Element in a List with Java](http://www.baeldung.com/find-list-element-java)
- [An Introduction to Java.util.Hashtable Class](http://www.baeldung.com/java-hash-table)
-- [Copy a List to Another List in Java](http://www.baeldung.com/java-copy-list-to-another)
-- [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max)
- [Java Null-Safe Streams from Collections](https://www.baeldung.com/java-null-safe-streams-from-collections)
-- [Remove All Occurrences of a Specific Value from a List](https://www.baeldung.com/java-remove-value-from-list)
- [Thread Safe LIFO Data Structure Implementations](https://www.baeldung.com/java-lifo-thread-safe)
-- [Collections.emptyList() vs. New List Instance](https://www.baeldung.com/java-collections-emptylist-new-list)
- [Differences Between Collection.clear() and Collection.removeAll()](https://www.baeldung.com/java-collection-clear-vs-removeall)
- [Performance of contains() in a HashSet vs ArrayList](https://www.baeldung.com/java-hashset-arraylist-contains-performance)
- [Time Complexity of Java Collections](https://www.baeldung.com/java-collections-complexity)
@@ -40,13 +25,8 @@
- [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections)
- [Guide to EnumSet](https://www.baeldung.com/java-enumset)
- [Removing Elements from Java Collections](https://www.baeldung.com/java-collection-remove-elements)
-- [Converting a Collection to ArrayList in Java](https://www.baeldung.com/java-convert-collection-arraylist)
-- [Java 8 Streams: Find Items From One List Based On Values From Another List](https://www.baeldung.com/java-streams-find-list-items)
- [Combining Different Types of Collections in Java](https://www.baeldung.com/java-combine-collections)
- [Sorting in Java](http://www.baeldung.com/java-sorting)
-- [A Guide to the Java LinkedList](http://www.baeldung.com/java-linkedlist)
-- [Java List UnsupportedOperationException](http://www.baeldung.com/java-list-unsupported-operation-exception)
- [Join and Split Arrays and Collections in Java](http://www.baeldung.com/java-join-and-split)
-- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality)
-- [Java List Initialization in One Line](https://www.baeldung.com/java-init-list-one-line)
-- [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist)
+- [A Guide to EnumMap](https://www.baeldung.com/java-enum-map)
+- [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator)
diff --git a/core-java/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java b/core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java
rename to core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java
diff --git a/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java b/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java
new file mode 100644
index 0000000000..5218332d60
--- /dev/null
+++ b/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java
@@ -0,0 +1,98 @@
+package com.baeldung.hashmapvshashtable;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Collections;
+import java.util.ConcurrentModificationException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+public class HashmapVsHashtableDifferenceUnitTest {
+
+ // null values
+ @Test(expected = NullPointerException.class)
+ public void givenHashtable_whenAddNullKey_thenNullPointerExceptionThrown() {
+ Hashtable table = new Hashtable();
+ table.put(null, "value");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void givenHashtable_whenAddNullValue_thenNullPointerExceptionThrown() {
+ Hashtable table = new Hashtable();
+ table.put("key", null);
+ }
+
+ @Test
+ public void givenHashmap_whenAddNullKeyAndValue_thenObjectAdded() {
+ HashMap map = new HashMap();
+ map.put(null, "value");
+ map.put("key1", null);
+ map.put("key2", null);
+
+ assertEquals(3, map.size());
+ }
+
+ // fail-fast iterator
+ @Test(expected = ConcurrentModificationException.class)
+ public void givenHashmap_whenModifyUnderlyingCollection_thenConcurrentModificationExceptionThrown() {
+ HashMap map = new HashMap();
+ map.put("key1", "value1");
+ map.put("key2", "value2");
+ map.put("key3", "value3");
+
+ Iterator iterator = map.keySet().iterator();
+ while(iterator.hasNext()){
+ iterator.next();
+ map.put("key4", "value4");
+ }
+ }
+
+ @Test
+ public void givenHashtable_whenModifyUnderlyingCollection_thenItHasNoEffectOnIteratedCollection() {
+ Hashtable table = new Hashtable();
+ table.put("key1", "value1");
+ table.put("key2", "value2");
+
+ List keysSelected = Lists.newArrayList();
+ Enumeration keys = table.keys();
+ while (keys.hasMoreElements()) {
+ String key = keys.nextElement();
+ keysSelected.add(key);
+
+ if (key.equals("key1")) {
+ table.put("key3", "value3");
+ }
+ }
+
+ assertEquals(2, keysSelected.size());
+ }
+
+ // synchronized map
+ @Test
+ public void givenHashmap_thenCreateSynchronizedMap() {
+ HashMap map = new HashMap();
+ map.put("key1", "value1");
+ map.put("key2", "value2");
+ map.put("key3", "value3");
+
+ Set> set = map.entrySet();
+ synchronized (map) {
+ Iterator> it = set.iterator();
+ while(it.hasNext()) {
+ Map.Entry elem = (Map.Entry)it.next();
+ }
+ }
+
+ Map syncMap = Collections.synchronizedMap(map);
+ }
+}
diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsEmpty.java b/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsEmpty.java
deleted file mode 100644
index 09ecebe47b..0000000000
--- a/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsEmpty.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.baeldung.java.collections;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
-
-class CollectionsEmpty {
-
- @Test
- public void givenArrayList_whenAddingElement_addsNewElement() {
- ArrayList mutableList = new ArrayList<>();
- mutableList.add("test");
-
- Assert.assertEquals(mutableList.size(), 1);
- Assert.assertEquals(mutableList.get(0), "test");
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void givenCollectionsEmptyList_whenAddingElement_throwsUnsupportedOperationException() {
- List immutableList = Collections.emptyList();
- immutableList.add("test");
- }
-
-}
diff --git a/core-java-collections/src/test/java/org/baeldung/java/lists/ListJUnitTest.java b/core-java-collections/src/test/java/org/baeldung/java/lists/ListJUnitTest.java
deleted file mode 100644
index 7dddf6c2ce..0000000000
--- a/core-java-collections/src/test/java/org/baeldung/java/lists/ListJUnitTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.baeldung.java.lists;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class ListJUnitTest {
-
- private final List list1 = Arrays.asList("1", "2", "3", "4");
- private final List list2 = Arrays.asList("1", "2", "3", "4");
- private final List list3 = Arrays.asList("1", "2", "4", "3");
-
- @Test
- public void whenTestingForEquality_ShouldBeEqual() throws Exception {
- Assert.assertEquals(list1, list2);
- Assert.assertNotSame(list1, list2);
- Assert.assertNotEquals(list1, list3);
- }
-}
diff --git a/core-java-concurrency/.gitignore b/core-java-concurrency-advanced/.gitignore
similarity index 100%
rename from core-java-concurrency/.gitignore
rename to core-java-concurrency-advanced/.gitignore
diff --git a/core-java-concurrency/README.md b/core-java-concurrency-advanced/README.md
similarity index 52%
rename from core-java-concurrency/README.md
rename to core-java-concurrency-advanced/README.md
index fbe50c2dfa..bcbec9d687 100644
--- a/core-java-concurrency/README.md
+++ b/core-java-concurrency-advanced/README.md
@@ -1,33 +1,24 @@
=========
-## Core Java Concurrency Examples
+## Core Java Concurrency Advanced Examples
### Relevant Articles:
-- [Guide To CompletableFuture](http://www.baeldung.com/java-completablefuture)
-- [A Guide to the Java ExecutorService](http://www.baeldung.com/java-executor-service-tutorial)
- [Introduction to Thread Pools in Java](http://www.baeldung.com/thread-pool-java-and-guava)
-- [Guide to java.util.concurrent.Future](http://www.baeldung.com/java-future)
- [Guide to CountDownLatch in Java](http://www.baeldung.com/java-countdown-latch)
- [Guide to java.util.concurrent.Locks](http://www.baeldung.com/java-concurrent-locks)
- [An Introduction to ThreadLocal in Java](http://www.baeldung.com/java-threadlocal)
-- [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep)
- [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator)
- [The Dining Philosophers Problem in Java](http://www.baeldung.com/java-dining-philoshophers)
- [Guide to the Java Phaser](http://www.baeldung.com/java-phaser)
-- [Guide to Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized)
- [An Introduction to Atomic Variables in Java](http://www.baeldung.com/java-atomic-variables)
- [CyclicBarrier in Java](http://www.baeldung.com/java-cyclic-barrier)
- [Guide to Volatile Keyword in Java](http://www.baeldung.com/java-volatile)
-- [Overview of the java.util.concurrent](http://www.baeldung.com/java-util-concurrent)
- [Semaphores in Java](http://www.baeldung.com/java-semaphore)
- [Daemon Threads in Java](http://www.baeldung.com/java-daemon-thread)
-- [Implementing a Runnable vs Extending a Thread](http://www.baeldung.com/java-runnable-vs-extending-thread)
-- [How to Kill a Java Thread](http://www.baeldung.com/java-thread-stop)
-- [ExecutorService - Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads)
-- [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify)
- [Priority-based Job Scheduling in Java](http://www.baeldung.com/java-priority-job-schedule)
-- [A Custom Spring SecurityConfigurer](http://www.baeldung.com/spring-security-custom-configurer)
-- [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle)
-- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable)
- [Brief Introduction to Java Thread.yield()](https://www.baeldung.com/java-thread-yield)
- [Print Even and Odd Numbers Using 2 Threads](https://www.baeldung.com/java-even-odd-numbers-with-2-threads)
+- [Java CyclicBarrier vs CountDownLatch](https://www.baeldung.com/java-cyclicbarrier-countdownlatch)
+- [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join)
+- [A Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random)
+- [The Thread.join() Method in Java](http://www.baeldung.com/java-thread-join)
\ No newline at end of file
diff --git a/core-java-concurrency/pom.xml b/core-java-concurrency-advanced/pom.xml
similarity index 78%
rename from core-java-concurrency/pom.xml
rename to core-java-concurrency-advanced/pom.xml
index bd22253c2c..1209cba619 100644
--- a/core-java-concurrency/pom.xml
+++ b/core-java-concurrency-advanced/pom.xml
@@ -2,10 +2,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0com.baeldung
- core-java-concurrency
+ core-java-concurrency-advanced0.1.0-SNAPSHOTjar
- core-java-concurrency
+ core-java-concurrency-advancedcom.baeldung
@@ -47,10 +47,20 @@
${avaitility.version}test
+
+ org.openjdk.jmh
+ jmh-core
+ ${jmh-core.version}
+
+
+ org.openjdk.jmh
+ jmh-generator-annprocess
+ ${jmh-generator-annprocess.version}
+
- core-java-concurrency
+ core-java-concurrency-advancedsrc/main/resources
@@ -69,6 +79,8 @@
3.6.11.7.0
+ 1.19
+ 1.19
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java
similarity index 94%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java
index e3a1629ce1..ef6b7ee8c8 100644
--- a/core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java
@@ -1,13 +1,13 @@
-package com.baeldung.concurrent.atomic;
-
-public class SafeCounterWithLock {
- private volatile int counter;
-
- int getValue() {
- return counter;
- }
-
- synchronized void increment() {
- counter++;
- }
-}
+package com.baeldung.concurrent.atomic;
+
+public class SafeCounterWithLock {
+ private volatile int counter;
+
+ int getValue() {
+ return counter;
+ }
+
+ synchronized void increment() {
+ counter++;
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java
similarity index 96%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java
index 18ade35efb..8b2aebba7c 100644
--- a/core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java
@@ -1,21 +1,21 @@
-package com.baeldung.concurrent.atomic;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class SafeCounterWithoutLock {
- private final AtomicInteger counter = new AtomicInteger(0);
-
- int getValue() {
- return counter.get();
- }
-
- void increment() {
- while(true) {
- int existingValue = getValue();
- int newValue = existingValue + 1;
- if(counter.compareAndSet(existingValue, newValue)) {
- return;
- }
- }
- }
-}
+package com.baeldung.concurrent.atomic;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class SafeCounterWithoutLock {
+ private final AtomicInteger counter = new AtomicInteger(0);
+
+ int getValue() {
+ return counter.get();
+ }
+
+ void increment() {
+ while(true) {
+ int existingValue = getValue();
+ int newValue = existingValue + 1;
+ if(counter.compareAndSet(existingValue, newValue)) {
+ return;
+ }
+ }
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java
similarity index 94%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java
index 500ef5bd7e..290c26b73d 100644
--- a/core-java-concurrency/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java
@@ -1,13 +1,13 @@
-package com.baeldung.concurrent.atomic;
-
-public class UnsafeCounter {
- private int counter;
-
- int getValue() {
- return counter;
- }
-
- void increment() {
- counter++;
- }
-}
+package com.baeldung.concurrent.atomic;
+
+public class UnsafeCounter {
+ private int counter;
+
+ int getValue() {
+ return counter;
+ }
+
+ void increment() {
+ counter++;
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/BrokenWorker.java
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExample.java
new file mode 100644
index 0000000000..08c7eeec03
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExample.java
@@ -0,0 +1,33 @@
+package com.baeldung.concurrent.countdownlatch;
+
+import java.util.concurrent.CountDownLatch;
+
+public class CountdownLatchCountExample {
+
+ private int count;
+
+ public CountdownLatchCountExample(int count) {
+ this.count = count;
+ }
+
+ public boolean callTwiceInSameThread() {
+ CountDownLatch countDownLatch = new CountDownLatch(count);
+ Thread t = new Thread(() -> {
+ countDownLatch.countDown();
+ countDownLatch.countDown();
+ });
+ t.start();
+
+ try {
+ countDownLatch.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return countDownLatch.getCount() == 0;
+ }
+
+ public static void main(String[] args) {
+ CountdownLatchCountExample ex = new CountdownLatchCountExample(2);
+ System.out.println("Is CountDown Completed : " + ex.callTwiceInSameThread());
+ }
+}
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExample.java
new file mode 100644
index 0000000000..1828b7f91e
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExample.java
@@ -0,0 +1,41 @@
+package com.baeldung.concurrent.countdownlatch;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class CountdownLatchResetExample {
+
+ private int count;
+ private int threadCount;
+ private final AtomicInteger updateCount;
+
+ CountdownLatchResetExample(int count, int threadCount) {
+ updateCount = new AtomicInteger(0);
+ this.count = count;
+ this.threadCount = threadCount;
+ }
+
+ public int countWaits() {
+ CountDownLatch countDownLatch = new CountDownLatch(count);
+ ExecutorService es = Executors.newFixedThreadPool(threadCount);
+ for (int i = 0; i < threadCount; i++) {
+ es.execute(() -> {
+ long prevValue = countDownLatch.getCount();
+ countDownLatch.countDown();
+ if (countDownLatch.getCount() != prevValue) {
+ updateCount.incrementAndGet();
+ }
+ });
+ }
+
+ es.shutdown();
+ return updateCount.get();
+ }
+
+ public static void main(String[] args) {
+ CountdownLatchResetExample ex = new CountdownLatchResetExample(5, 20);
+ System.out.println("Count : " + ex.countWaits());
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/WaitingWorker.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/countdownlatch/Worker.java
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExample.java
new file mode 100644
index 0000000000..7c1299da62
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExample.java
@@ -0,0 +1,45 @@
+package com.baeldung.concurrent.cyclicbarrier;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class CyclicBarrierCompletionMethodExample {
+
+ private int count;
+ private int threadCount;
+ private final AtomicInteger updateCount;
+
+ CyclicBarrierCompletionMethodExample(int count, int threadCount) {
+ updateCount = new AtomicInteger(0);
+ this.count = count;
+ this.threadCount = threadCount;
+ }
+
+ public int countTrips() {
+
+ CyclicBarrier cyclicBarrier = new CyclicBarrier(count, () -> {
+ updateCount.incrementAndGet();
+ });
+
+ ExecutorService es = Executors.newFixedThreadPool(threadCount);
+ for (int i = 0; i < threadCount; i++) {
+ es.execute(() -> {
+ try {
+ cyclicBarrier.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+ es.shutdown();
+ return updateCount.get();
+ }
+
+ public static void main(String[] args) {
+ CyclicBarrierCompletionMethodExample ex = new CyclicBarrierCompletionMethodExample(5, 20);
+ System.out.println("Count : " + ex.countTrips());
+ }
+}
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExample.java
new file mode 100644
index 0000000000..9d637b428b
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExample.java
@@ -0,0 +1,32 @@
+package com.baeldung.concurrent.cyclicbarrier;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+public class CyclicBarrierCountExample {
+
+ private int count;
+
+ public CyclicBarrierCountExample(int count) {
+ this.count = count;
+ }
+
+ public boolean callTwiceInSameThread() {
+ CyclicBarrier cyclicBarrier = new CyclicBarrier(count);
+ Thread t = new Thread(() -> {
+ try {
+ cyclicBarrier.await();
+ cyclicBarrier.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ e.printStackTrace();
+ }
+ });
+ t.start();
+ return cyclicBarrier.isBroken();
+ }
+
+ public static void main(String[] args) {
+ CyclicBarrierCountExample ex = new CyclicBarrierCountExample(7);
+ System.out.println("Count : " + ex.callTwiceInSameThread());
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExample.java
new file mode 100644
index 0000000000..76b6198bc4
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExample.java
@@ -0,0 +1,46 @@
+package com.baeldung.concurrent.cyclicbarrier;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class CyclicBarrierResetExample {
+
+ private int count;
+ private int threadCount;
+ private final AtomicInteger updateCount;
+
+ CyclicBarrierResetExample(int count, int threadCount) {
+ updateCount = new AtomicInteger(0);
+ this.count = count;
+ this.threadCount = threadCount;
+ }
+
+ public int countWaits() {
+
+ CyclicBarrier cyclicBarrier = new CyclicBarrier(count);
+
+ ExecutorService es = Executors.newFixedThreadPool(threadCount);
+ for (int i = 0; i < threadCount; i++) {
+ es.execute(() -> {
+ try {
+ if (cyclicBarrier.getNumberWaiting() > 0) {
+ updateCount.incrementAndGet();
+ }
+ cyclicBarrier.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+ es.shutdown();
+ return updateCount.get();
+ }
+
+ public static void main(String[] args) {
+ CyclicBarrierResetExample ex = new CyclicBarrierResetExample(7, 20);
+ System.out.println("Count : " + ex.countWaits());
+ }
+}
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/MultipleThreadsExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/MultipleThreadsExample.java
new file mode 100644
index 0000000000..492466e0c3
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/MultipleThreadsExample.java
@@ -0,0 +1,12 @@
+package com.baeldung.concurrent.daemon;
+
+public class MultipleThreadsExample {
+ public static void main(String[] args) {
+ NewThread t1 = new NewThread();
+ t1.setName("MyThread-1");
+ NewThread t2 = new NewThread();
+ t2.setName("MyThread-2");
+ t1.start();
+ t2.start();
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/daemon/NewThread.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/NewThread.java
similarity index 60%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/daemon/NewThread.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/NewThread.java
index 4d87978070..370ce99c09 100644
--- a/core-java-concurrency/src/main/java/com/baeldung/concurrent/daemon/NewThread.java
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/NewThread.java
@@ -1,14 +1,18 @@
package com.baeldung.concurrent.daemon;
public class NewThread extends Thread {
-
public void run() {
long startTime = System.currentTimeMillis();
while (true) {
for (int i = 0; i < 10; i++) {
- System.out.println("New Thread is running..." + i);
+ System.out.println(this.getName() + ": New Thread is running..." + i);
+ try {
+ //Wait for one sec so it doesn't print too fast
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
-
// prevent the Thread to run forever. It will finish it's execution after 2 seconds
if (System.currentTimeMillis() - startTime > 2000) {
Thread.currentThread().interrupt();
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/SingleThreadExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/SingleThreadExample.java
new file mode 100644
index 0000000000..16d8b2be1e
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/daemon/SingleThreadExample.java
@@ -0,0 +1,8 @@
+package com.baeldung.concurrent.daemon;
+
+public class SingleThreadExample {
+ public static void main(String[] args) {
+ NewThread t = new NewThread();
+ t.start();
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/DiningPhilosophers.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddSemaphore.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/evenandodd/PrintEvenOddWaitNotify.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/ReentrantLockWithCondition.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SharedObjectWithLock.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/StampedLockDemo.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLock.java
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/AverageCalculator.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/AverageCalculator.java
new file mode 100644
index 0000000000..a548b5d4a7
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/AverageCalculator.java
@@ -0,0 +1,20 @@
+package com.baeldung.concurrent.parameter;
+
+import java.util.concurrent.Callable;
+import java.util.stream.IntStream;
+
+public class AverageCalculator implements Callable {
+
+ int[] numbers;
+
+ public AverageCalculator(int... parameter) {
+ this.numbers = parameter == null ? new int[0] : parameter;
+ }
+
+ @Override
+ public Double call() throws Exception {
+ return IntStream.of(this.numbers)
+ .average()
+ .orElse(0d);
+ }
+}
diff --git a/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/ParameterizedThreadExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/ParameterizedThreadExample.java
new file mode 100644
index 0000000000..73c61f3fb1
--- /dev/null
+++ b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/parameter/ParameterizedThreadExample.java
@@ -0,0 +1,32 @@
+package com.baeldung.concurrent.parameter;
+
+import java.util.concurrent.Callable;
+import java.util.stream.IntStream;
+
+public class ParameterizedThreadExample {
+
+ public static void parameterisedThreadAnonymousClass() {
+ final String parameter = "123";
+ Thread parameterizedThread = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ System.out.println(Thread.currentThread()
+ .getName() + " : " + parameter);
+ }
+ });
+
+ parameterizedThread.start();
+ }
+
+ public static Callable sumCalculator(int... numbers) {
+ return () -> numbers != null ? IntStream.of(numbers)
+ .sum() : 0;
+ }
+
+ public static Callable averageCalculator(int... numbers) {
+ return () -> numbers != null ? IntStream.of(numbers)
+ .average()
+ .orElse(0d) : 0d;
+ }
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/phaser/LongRunningAction.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/Job.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/JobPriority.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobScheduler.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/CounterUsingMutex.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/DelayQueueUsingTimedSemaphore.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/semaphores/LoginQueueUsingSemaphore.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/SharedObject.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/yield/ThreadYield.java
diff --git a/core-java/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveAction.java
diff --git a/core-java/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/CustomRecursiveTask.java
diff --git a/core-java/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/forkjoin/util/PoolUtil.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/threadlocal/Context.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/Context.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/threadlocal/Context.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/Context.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/SharedMapWithUserContext.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/ThreadLocalWithUserContext.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/threadlocal/UserRepository.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/UserRepository.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/threadlocal/UserRepository.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocal/UserRepository.java
diff --git a/core-java/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java
diff --git a/core-java/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/threadpool/CountingTask.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/CountingTask.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/threadpool/CountingTask.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/CountingTask.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/ExitingExecutorServiceExample.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/threadpool/TreeNode.java b/core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/TreeNode.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/threadpool/TreeNode.java
rename to core-java-concurrency-advanced/src/main/java/com/baeldung/threadpool/TreeNode.java
diff --git a/core-java-concurrency/src/main/java/log4j.properties b/core-java-concurrency-advanced/src/main/java/log4j.properties
similarity index 100%
rename from core-java-concurrency/src/main/java/log4j.properties
rename to core-java-concurrency-advanced/src/main/java/log4j.properties
diff --git a/core-java-concurrency/src/main/resources/logback.xml b/core-java-concurrency-advanced/src/main/resources/logback.xml
similarity index 100%
rename from core-java-concurrency/src/main/resources/logback.xml
rename to core-java-concurrency-advanced/src/main/resources/logback.xml
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/accumulator/LongAccumulatorUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/adder/LongAdderUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java
similarity index 97%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java
index 4eead471f8..c3c44b40cf 100644
--- a/core-java-concurrency/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterIntegrationTest.java
@@ -1,38 +1,38 @@
-package com.baeldung.concurrent.atomic;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.IntStream;
-
-import org.junit.Test;
-
-public class ThreadSafeCounterIntegrationTest {
-
- @Test
- public void givenMultiThread_whenSafeCounterWithLockIncrement() throws InterruptedException {
- ExecutorService service = Executors.newFixedThreadPool(3);
- SafeCounterWithLock safeCounter = new SafeCounterWithLock();
-
- IntStream.range(0, 1000)
- .forEach(count -> service.submit(safeCounter::increment));
- service.awaitTermination(100, TimeUnit.MILLISECONDS);
-
- assertEquals(1000, safeCounter.getValue());
- }
-
- @Test
- public void givenMultiThread_whenSafeCounterWithoutLockIncrement() throws InterruptedException {
- ExecutorService service = Executors.newFixedThreadPool(3);
- SafeCounterWithoutLock safeCounter = new SafeCounterWithoutLock();
-
- IntStream.range(0, 1000)
- .forEach(count -> service.submit(safeCounter::increment));
- service.awaitTermination(100, TimeUnit.MILLISECONDS);
-
- assertEquals(1000, safeCounter.getValue());
- }
-
-}
+package com.baeldung.concurrent.atomic;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
+import org.junit.Test;
+
+public class ThreadSafeCounterIntegrationTest {
+
+ @Test
+ public void givenMultiThread_whenSafeCounterWithLockIncrement() throws InterruptedException {
+ ExecutorService service = Executors.newFixedThreadPool(3);
+ SafeCounterWithLock safeCounter = new SafeCounterWithLock();
+
+ IntStream.range(0, 1000)
+ .forEach(count -> service.submit(safeCounter::increment));
+ service.awaitTermination(100, TimeUnit.MILLISECONDS);
+
+ assertEquals(1000, safeCounter.getValue());
+ }
+
+ @Test
+ public void givenMultiThread_whenSafeCounterWithoutLockIncrement() throws InterruptedException {
+ ExecutorService service = Executors.newFixedThreadPool(3);
+ SafeCounterWithoutLock safeCounter = new SafeCounterWithoutLock();
+
+ IntStream.range(0, 1000)
+ .forEach(count -> service.submit(safeCounter::increment));
+ service.awaitTermination(100, TimeUnit.MILLISECONDS);
+
+ assertEquals(1000, safeCounter.getValue());
+ }
+
+}
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java
similarity index 97%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java
index cc7cc18bb5..bf451e58de 100644
--- a/core-java-concurrency/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java
@@ -1,33 +1,33 @@
-package com.baeldung.concurrent.atomic;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.IntStream;
-
-import org.junit.Test;
-
-/**
- * This test shows the behaviour of a thread-unsafe class in a multithreaded scenario. We are calling
- * the increment methods 1000 times from a pool of 3 threads. In most of the cases, the counter will
- * less than 1000, because of lost updates, however, occasionally it may reach 1000, when no threads
- * called the method simultaneously. This may cause the build to fail occasionally. Hence excluding this
- * test from build by adding this in manual test
- */
-public class ThreadUnsafeCounterManualTest {
-
- @Test
- public void givenMultiThread_whenUnsafeCounterIncrement() throws InterruptedException {
- ExecutorService service = Executors.newFixedThreadPool(3);
- UnsafeCounter unsafeCounter = new UnsafeCounter();
-
- IntStream.range(0, 1000)
- .forEach(count -> service.submit(unsafeCounter::increment));
- service.awaitTermination(100, TimeUnit.MILLISECONDS);
-
- assertEquals(1000, unsafeCounter.getValue());
- }
-
-}
+package com.baeldung.concurrent.atomic;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
+import org.junit.Test;
+
+/**
+ * This test shows the behaviour of a thread-unsafe class in a multithreaded scenario. We are calling
+ * the increment methods 1000 times from a pool of 3 threads. In most of the cases, the counter will
+ * less than 1000, because of lost updates, however, occasionally it may reach 1000, when no threads
+ * called the method simultaneously. This may cause the build to fail occasionally. Hence excluding this
+ * test from build by adding this in manual test
+ */
+public class ThreadUnsafeCounterManualTest {
+
+ @Test
+ public void givenMultiThread_whenUnsafeCounterIncrement() throws InterruptedException {
+ ExecutorService service = Executors.newFixedThreadPool(3);
+ UnsafeCounter unsafeCounter = new UnsafeCounter();
+
+ IntStream.range(0, 1000)
+ .forEach(count -> service.submit(unsafeCounter::increment));
+ service.awaitTermination(100, TimeUnit.MILLISECONDS);
+
+ assertEquals(1000, unsafeCounter.getValue());
+ }
+
+}
diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExampleUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExampleUnitTest.java
new file mode 100644
index 0000000000..835efa53f2
--- /dev/null
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchCountExampleUnitTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.concurrent.countdownlatch;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class CountdownLatchCountExampleUnitTest {
+
+ @Test
+ public void whenCountDownLatch_completed() {
+ CountdownLatchCountExample ex = new CountdownLatchCountExample(2);
+ boolean isCompleted = ex.callTwiceInSameThread();
+ assertTrue(isCompleted);
+ }
+}
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchExampleIntegrationTest.java
diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java
new file mode 100644
index 0000000000..d2d43f6312
--- /dev/null
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/countdownlatch/CountdownLatchResetExampleUnitTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.concurrent.countdownlatch;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class CountdownLatchResetExampleUnitTest {
+
+ @Test
+ public void whenCountDownLatch_noReset() {
+ CountdownLatchResetExample ex = new CountdownLatchResetExample(7,20);
+ int lineCount = ex.countWaits();
+ assertTrue(lineCount <= 7);
+ }
+}
diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExampleUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExampleUnitTest.java
new file mode 100644
index 0000000000..310063c86c
--- /dev/null
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCompletionMethodExampleUnitTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.concurrent.cyclicbarrier;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class CyclicBarrierCompletionMethodExampleUnitTest {
+
+ @Test
+ public void whenCyclicBarrier_countTrips() {
+ CyclicBarrierCompletionMethodExample ex = new CyclicBarrierCompletionMethodExample(7,20);
+ int lineCount = ex.countTrips();
+ assertEquals(2, lineCount);
+ }
+}
diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExampleUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExampleUnitTest.java
new file mode 100644
index 0000000000..9b7f3d9945
--- /dev/null
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierCountExampleUnitTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.concurrent.cyclicbarrier;
+
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+
+public class CyclicBarrierCountExampleUnitTest {
+
+ @Test
+ public void whenCyclicBarrier_notCompleted() {
+ CyclicBarrierCountExample ex = new CyclicBarrierCountExample(2);
+ boolean isCompleted = ex.callTwiceInSameThread();
+ assertFalse(isCompleted);
+ }
+}
diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExampleUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExampleUnitTest.java
new file mode 100644
index 0000000000..8d2b148f06
--- /dev/null
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierResetExampleUnitTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.concurrent.cyclicbarrier;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class CyclicBarrierResetExampleUnitTest {
+
+ @Test
+ public void whenCyclicBarrier_reset() {
+ CyclicBarrierResetExample ex = new CyclicBarrierResetExample(7,20);
+ int lineCount = ex.countWaits();
+ assertTrue(lineCount > 7);
+ }
+}
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/daemon/DaemonThreadUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SharedObjectWithLockManualTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/locks/SynchronizedHashMapWithRWLockManualTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/phaser/PhaserUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/prioritytaskexecution/PriorityJobSchedulerUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/semaphores/SemaphoresManualTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java
diff --git a/core-java/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/java8/Java8ForkJoinIntegrationTest.java
diff --git a/core-java-concurrency-advanced/src/test/java/com/baeldung/parameters/ParameterizedThreadUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/parameters/ParameterizedThreadUnitTest.java
new file mode 100644
index 0000000000..21b374e609
--- /dev/null
+++ b/core-java-concurrency-advanced/src/test/java/com/baeldung/parameters/ParameterizedThreadUnitTest.java
@@ -0,0 +1,43 @@
+package com.baeldung.parameters;
+
+import com.baeldung.concurrent.parameter.AverageCalculator;
+import org.junit.Test;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.stream.IntStream;
+
+import static org.junit.Assert.assertEquals;
+
+public class ParameterizedThreadUnitTest {
+
+ @Test
+ public void whenSendingParameterToCallable_thenSuccessful() throws Exception {
+ ExecutorService executorService = Executors.newSingleThreadExecutor();
+ Future result = executorService.submit(new AverageCalculator(1, 2, 3));
+ try {
+ assertEquals(Double.valueOf(2.0), result.get());
+ } finally {
+ executorService.shutdown();
+ }
+ }
+
+ @Test
+ public void whenParametersToThreadWithLamda_thenParametersPassedCorrectly() throws Exception {
+ ExecutorService executorService = Executors.newFixedThreadPool(2);
+ int[] numbers = new int[] { 4, 5, 6 };
+ try {
+ Future sumResult = executorService.submit(() -> IntStream.of(numbers)
+ .sum());
+ Future averageResult = executorService.submit(() -> IntStream.of(numbers)
+ .average()
+ .orElse(0d));
+ assertEquals(Integer.valueOf(15), sumResult.get());
+ assertEquals(Double.valueOf(5.0), averageResult.get());
+ } finally {
+ executorService.shutdown();
+ }
+ }
+
+}
diff --git a/core-java/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/thread/join/ThreadJoinUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocal/ThreadLocalIntegrationTest.java
diff --git a/core-java/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/threadlocalrandom/ThreadLocalRandomIntegrationTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/CoreThreadPoolIntegrationTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java b/core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java
rename to core-java-concurrency-advanced/src/test/java/com/baeldung/threadpool/GuavaThreadPoolIntegrationTest.java
diff --git a/core-java-concurrency/src/test/resources/.gitignore b/core-java-concurrency-advanced/src/test/resources/.gitignore
similarity index 100%
rename from core-java-concurrency/src/test/resources/.gitignore
rename to core-java-concurrency-advanced/src/test/resources/.gitignore
diff --git a/core-java-concurrency-basic/.gitignore b/core-java-concurrency-basic/.gitignore
new file mode 100644
index 0000000000..3de4cc647e
--- /dev/null
+++ b/core-java-concurrency-basic/.gitignore
@@ -0,0 +1,26 @@
+*.class
+
+0.*
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+.resourceCache
+
+# Packaged files #
+*.jar
+*.war
+*.ear
+
+# Files generated by integration tests
+*.txt
+backup-pom.xml
+/bin/
+/temp
+
+#IntelliJ specific
+.idea/
+*.iml
\ No newline at end of file
diff --git a/core-java-concurrency-basic/README.md b/core-java-concurrency-basic/README.md
new file mode 100644
index 0000000000..1c43149d03
--- /dev/null
+++ b/core-java-concurrency-basic/README.md
@@ -0,0 +1,17 @@
+=========
+
+## Core Java Concurrency Basic Examples
+
+### Relevant Articles:
+- [Guide To CompletableFuture](http://www.baeldung.com/java-completablefuture)
+- [A Guide to the Java ExecutorService](http://www.baeldung.com/java-executor-service-tutorial)
+- [Guide to java.util.concurrent.Future](http://www.baeldung.com/java-future)
+- [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep)
+- [Guide to Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized)
+- [Overview of the java.util.concurrent](http://www.baeldung.com/java-util-concurrent)
+- [Implementing a Runnable vs Extending a Thread](http://www.baeldung.com/java-runnable-vs-extending-thread)
+- [How to Kill a Java Thread](http://www.baeldung.com/java-thread-stop)
+- [ExecutorService - Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads)
+- [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify)
+- [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle)
+- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable)
\ No newline at end of file
diff --git a/core-java-concurrency-basic/pom.xml b/core-java-concurrency-basic/pom.xml
new file mode 100644
index 0000000000..3544403aca
--- /dev/null
+++ b/core-java-concurrency-basic/pom.xml
@@ -0,0 +1,55 @@
+
+ 4.0.0
+ com.baeldung
+ core-java-concurrency-basic
+ 0.1.0-SNAPSHOT
+ jar
+ core-java-concurrency-basic
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+ test
+
+
+ com.jayway.awaitility
+ awaitility
+ ${avaitility.version}
+ test
+
+
+
+
+ core-java-concurrency-basic
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ 3.5
+
+ 3.6.1
+ 1.7.0
+
+
+
diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java
new file mode 100644
index 0000000000..0989195ba7
--- /dev/null
+++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java
@@ -0,0 +1,52 @@
+package com.baeldung.concurrent.Scheduledexecutorservice;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+
+public class ScheduledExecutorServiceDemo {
+
+ private void execute() {
+ ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+ getTasksToRun().apply(executorService);
+ executorService.shutdown();
+ }
+
+ private void executeWithMultiThread() {
+ ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2);
+ getTasksToRun().apply(executorService);
+ executorService.shutdown();
+ }
+
+ private Function getTasksToRun() {
+ return (executorService -> {
+ ScheduledFuture> scheduledFuture1 = executorService.schedule(() -> {
+ // Task
+ }, 1, TimeUnit.SECONDS);
+
+ ScheduledFuture> scheduledFuture2 = executorService.scheduleAtFixedRate(() -> {
+ // Task
+ }, 1, 10, TimeUnit.SECONDS);
+
+ ScheduledFuture> scheduledFuture3 = executorService.scheduleWithFixedDelay(() -> {
+ // Task
+ }, 1, 10, TimeUnit.SECONDS);
+
+ ScheduledFuture scheduledFuture4 = executorService.schedule(() -> {
+ // Task
+ return "Hellow world";
+ }, 1, TimeUnit.SECONDS);
+ return null;
+ });
+ }
+
+ public static void main(String... args) {
+ ScheduledExecutorServiceDemo demo = new ScheduledExecutorServiceDemo();
+ demo.execute();
+ demo.executeWithMultiThread();
+ }
+
+
+}
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/callable/FactorialTask.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/executor/Invoker.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/Invoker.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/executor/Invoker.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executor/Invoker.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/DelayedCallable.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/executorservice/Task.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/Task.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/executorservice/Task.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/executorservice/Task.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FactorialSquareCalculator.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/future/FutureDemo.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FutureDemo.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/future/FutureDemo.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/FutureDemo.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/future/SquareCalculator.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/EventLoggingTask.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/runnable/TaskRunner.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadA.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/ThreadB.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/sleepwait/WaitSleepExample.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedBlocks.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizedMethods.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadfactory/Task.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Task.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadfactory/Task.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadfactory/Task.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/BlockedState.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/NewState.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/RunnableState.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TerminatedState.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/TimedWaitingState.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadlifecycle/WaitingState.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Data.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/NetworkDriver.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Receiver.java
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java
similarity index 100%
rename from core-java-concurrency/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java
rename to core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/waitandnotify/Sender.java
diff --git a/spring-mybatis/src/main/resources/logback.xml b/core-java-concurrency-basic/src/main/resources/logback.xml
similarity index 57%
rename from spring-mybatis/src/main/resources/logback.xml
rename to core-java-concurrency-basic/src/main/resources/logback.xml
index 7d900d8ea8..56af2d397e 100644
--- a/spring-mybatis/src/main/resources/logback.xml
+++ b/core-java-concurrency-basic/src/main/resources/logback.xml
@@ -7,6 +7,12 @@
+
+
+
+
+
+
diff --git a/core-java-concurrency/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/callable/FactorialTaskManualTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishManualTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/FactorialSquareCalculatorUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/future/SquareCalculatorIntegrationTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/runnable/RunnableVsThreadLiveTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/stopping/StopThreadManualTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSychronizedBlockUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/synchronize/BaeldungSynchronizeMethodsUnitTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/waitandnotify/NetworkIntegrationTest.java
diff --git a/core-java-concurrency/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java b/core-java-concurrency-basic/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java
similarity index 100%
rename from core-java-concurrency/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java
rename to core-java-concurrency-basic/src/test/java/com/baeldung/java8/Java8ExecutorServiceIntegrationTest.java
diff --git a/spring-rest-template/.gitignore b/core-java-concurrency-basic/src/test/resources/.gitignore
similarity index 92%
rename from spring-rest-template/.gitignore
rename to core-java-concurrency-basic/src/test/resources/.gitignore
index afdfaa6ded..83c05e60c8 100644
--- a/spring-rest-template/.gitignore
+++ b/core-java-concurrency-basic/src/test/resources/.gitignore
@@ -6,7 +6,6 @@
/data
/src/main/webapp/WEB-INF/classes
*/META-INF/*
-*/.idea/*
# Packaged files #
*.jar
diff --git a/core-java-concurrency/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java b/core-java-concurrency/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java
deleted file mode 100644
index b77019eea5..0000000000
--- a/core-java-concurrency/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.baeldung.concurrent.Scheduledexecutorservice;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-public class ScheduledExecutorServiceDemo {
-
- public void execute() {
- ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
-
- ScheduledFuture> scheduledFuture = executorService.schedule(() -> {
- // Task
- }, 1, TimeUnit.SECONDS);
-
- executorService.scheduleAtFixedRate(() -> {
- // Task
- }, 1, 10, TimeUnit.SECONDS);
-
- executorService.scheduleWithFixedDelay(() -> {
- // Task
- }, 1, 10, TimeUnit.SECONDS);
-
- Future future = executorService.schedule(() -> {
- // Task
- return "Hellow world";
- }, 1, TimeUnit.SECONDS);
-
- executorService.shutdown();
- }
-
-}
diff --git a/core-java-io/README.md b/core-java-io/README.md
index c81e466b57..2ad980ca6a 100644
--- a/core-java-io/README.md
+++ b/core-java-io/README.md
@@ -34,3 +34,6 @@
- [Read a File into an ArrayList](https://www.baeldung.com/java-file-to-arraylist)
- [Guide to Java OutputStream](https://www.baeldung.com/java-outputstream)
- [Reading a CSV File into an Array](https://www.baeldung.com/java-csv-file-array)
+- [Guide to BufferedReader](https://www.baeldung.com/java-buffered-reader)
+- [How to Get the File Extension of a File in Java](http://www.baeldung.com/java-file-extension)
+- [Getting a File’s Mime Type in Java](http://www.baeldung.com/java-file-mime-type)
\ No newline at end of file
diff --git a/core-java-io/pom.xml b/core-java-io/pom.xml
index efa32b8e3e..1f2d52de81 100644
--- a/core-java-io/pom.xml
+++ b/core-java-io/pom.xml
@@ -160,6 +160,17 @@
${opencsv.version}test
+
+
+ org.apache.tika
+ tika-core
+ ${tika.version}
+
+
+ net.sf.jmimemagic
+ jmimemagic
+ ${jmime-magic.version}
+
@@ -236,7 +247,7 @@
- 2.8.5
+ 2.9.73.5
@@ -264,6 +275,9 @@
2.1.0.11.192.4.5
+
+ 1.18
+ 0.1.5
\ No newline at end of file
diff --git a/core-java-io/src/main/java/com/baeldung/download/FileDownload.java b/core-java-io/src/main/java/com/baeldung/download/FileDownload.java
index c7dd154023..a099406d4c 100644
--- a/core-java-io/src/main/java/com/baeldung/download/FileDownload.java
+++ b/core-java-io/src/main/java/com/baeldung/download/FileDownload.java
@@ -45,6 +45,7 @@ public class FileDownload {
FileOutputStream fileOutputStream = new FileOutputStream(localFilename); FileChannel fileChannel = fileOutputStream.getChannel()) {
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
+ fileOutputStream.close();
}
}
diff --git a/core-java/src/main/java/com/baeldung/extension/Extension.java b/core-java-io/src/main/java/com/baeldung/extension/Extension.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/extension/Extension.java
rename to core-java-io/src/main/java/com/baeldung/extension/Extension.java
diff --git a/core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java b/core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java
rename to core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java
diff --git a/core-java/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java b/core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java
rename to core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java
diff --git a/core-java/src/test/resources/META-INF/mime.types b/core-java-io/src/test/resources/META-INF/mime.types
similarity index 100%
rename from core-java/src/test/resources/META-INF/mime.types
rename to core-java-io/src/test/resources/META-INF/mime.types
diff --git a/core-java/src/test/resources/product.png b/core-java-io/src/test/resources/product.png
similarity index 100%
rename from core-java/src/test/resources/product.png
rename to core-java-io/src/test/resources/product.png
diff --git a/core-java-lang-oop/.gitignore b/core-java-lang-oop/.gitignore
new file mode 100644
index 0000000000..3de4cc647e
--- /dev/null
+++ b/core-java-lang-oop/.gitignore
@@ -0,0 +1,26 @@
+*.class
+
+0.*
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+.resourceCache
+
+# Packaged files #
+*.jar
+*.war
+*.ear
+
+# Files generated by integration tests
+*.txt
+backup-pom.xml
+/bin/
+/temp
+
+#IntelliJ specific
+.idea/
+*.iml
\ No newline at end of file
diff --git a/core-java-lang-oop/README.md b/core-java-lang-oop/README.md
new file mode 100644
index 0000000000..bbc3d26c99
--- /dev/null
+++ b/core-java-lang-oop/README.md
@@ -0,0 +1,24 @@
+=========
+
+## Core Java Lang OOP Cookbooks and Examples
+
+### Relevant Articles:
+- [Guide to hashCode() in Java](http://www.baeldung.com/java-hashcode)
+- [A Guide to the Static Keyword in Java](http://www.baeldung.com/java-static)
+- [A Guide to Java Initialization](http://www.baeldung.com/java-initialization)
+- [Polymorphism in Java](http://www.baeldung.com/java-polymorphism)
+- [Method Overloading and Overriding in Java](http://www.baeldung.com/java-method-overload-override)
+- [How to Make a Deep Copy of an Object in Java](http://www.baeldung.com/java-deep-copy)
+- [Guide to Inheritance in Java](http://www.baeldung.com/java-inheritance)
+- [Object Type Casting in Java](http://www.baeldung.com/java-type-casting)
+- [The "final" Keyword in Java](http://www.baeldung.com/java-final)
+- [Type Erasure in Java Explained](http://www.baeldung.com/java-type-erasure)
+- [Pass-By-Value as a Parameter Passing Mechanism in Java](http://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
+- [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding)
+- [Access Modifiers in Java](http://www.baeldung.com/java-access-modifiers)
+- [Guide to the super Java Keyword](http://www.baeldung.com/java-super)
+- [Guide to the this Java Keyword](http://www.baeldung.com/java-this)
+- [Immutable Objects in Java](http://www.baeldung.com/java-immutable-object)
+- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](http://www.baeldung.com/java-inheritance-composition)
+- [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors)
+- [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts)
diff --git a/core-java-lang-oop/pom.xml b/core-java-lang-oop/pom.xml
new file mode 100644
index 0000000000..262408c024
--- /dev/null
+++ b/core-java-lang-oop/pom.xml
@@ -0,0 +1,91 @@
+
+ 4.0.0
+ com.baeldung
+ core-java-lang-oop
+ 0.1.0-SNAPSHOT
+ jar
+ core-java-lang-oop
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+ com.google.code.gson
+ gson
+ ${gson.version}
+
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+ org.slf4j
+ log4j-over-slf4j
+ ${org.slf4j.version}
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+ nl.jqno.equalsverifier
+ equalsverifier
+ ${equalsverifier.version}
+ test
+
+
+
+
+ core-java-lang-oop
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+
+ 2.8.5
+ 2.8.2
+
+
+ 3.5
+ 1.16.12
+
+ 3.10.0
+ 3.0.3
+
+
+
diff --git a/core-java-lang/src/main/java/com/baeldung/accessmodifiers/Public.java b/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/Public.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/accessmodifiers/Public.java
rename to core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/Public.java
diff --git a/core-java-lang/src/main/java/com/baeldung/accessmodifiers/SubClass.java b/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SubClass.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/accessmodifiers/SubClass.java
rename to core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SubClass.java
diff --git a/core-java-lang/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java b/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java
rename to core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java
diff --git a/core-java-lang/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java b/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java
rename to core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java
diff --git a/core-java-lang/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java b/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java
rename to core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java
diff --git a/core-java-lang/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java b/core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java
rename to core-java-lang-oop/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java
diff --git a/core-java-lang/src/main/java/com/baeldung/casting/Animal.java b/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/casting/Animal.java
rename to core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java
diff --git a/core-java-lang/src/main/java/com/baeldung/casting/AnimalFeeder.java b/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/casting/AnimalFeeder.java
rename to core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java
diff --git a/core-java-lang/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java b/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java
rename to core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java
diff --git a/core-java-lang/src/main/java/com/baeldung/casting/Cat.java b/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/casting/Cat.java
rename to core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java
diff --git a/core-java-lang/src/main/java/com/baeldung/casting/Dog.java b/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/casting/Dog.java
rename to core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java
diff --git a/core-java-lang/src/main/java/com/baeldung/casting/Mew.java b/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/casting/Mew.java
rename to core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java
diff --git a/core-java/src/main/java/com/baeldung/constructors/BankAccount.java b/core-java-lang-oop/src/main/java/com/baeldung/constructors/BankAccount.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/constructors/BankAccount.java
rename to core-java-lang-oop/src/main/java/com/baeldung/constructors/BankAccount.java
diff --git a/core-java/src/main/java/com/baeldung/constructors/Transaction.java b/core-java-lang-oop/src/main/java/com/baeldung/constructors/Transaction.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/constructors/Transaction.java
rename to core-java-lang-oop/src/main/java/com/baeldung/constructors/Transaction.java
diff --git a/core-java-lang/src/main/java/com/baeldung/deepcopy/Address.java b/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/deepcopy/Address.java
rename to core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java
diff --git a/core-java-lang/src/main/java/com/baeldung/deepcopy/User.java b/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/deepcopy/User.java
rename to core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java
diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Money.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Money.java
new file mode 100644
index 0000000000..60c043545d
--- /dev/null
+++ b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Money.java
@@ -0,0 +1,36 @@
+package com.baeldung.equalshashcode;
+
+class Money {
+
+ int amount;
+ String currencyCode;
+
+ Money(int amount, String currencyCode) {
+ this.amount = amount;
+ this.currencyCode = currencyCode;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof Money))
+ return false;
+ Money other = (Money)o;
+ boolean currencyCodeEquals = (this.currencyCode == null && other.currencyCode == null)
+ || (this.currencyCode != null && this.currencyCode.equals(other.currencyCode));
+ return this.amount == other.amount
+ && currencyCodeEquals;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + amount;
+ if (currencyCode != null) {
+ result = 31 * result + currencyCode.hashCode();
+ }
+ return result;
+ }
+
+}
diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Team.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Team.java
new file mode 100644
index 0000000000..c2dee1de6b
--- /dev/null
+++ b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Team.java
@@ -0,0 +1,39 @@
+package com.baeldung.equalshashcode;
+
+class Team {
+
+ final String city;
+ final String department;
+
+ Team(String city, String department) {
+ this.city = city;
+ this.department = department;
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof Team))
+ return false;
+ Team otherTeam = (Team)o;
+ boolean cityEquals = (this.city == null && otherTeam.city == null)
+ || this.city != null && this.city.equals(otherTeam.city);
+ boolean departmentEquals = (this.department == null && otherTeam.department == null)
+ || this.department != null && this.department.equals(otherTeam.department);
+ return cityEquals && departmentEquals;
+ }
+
+ @Override
+ public final int hashCode() {
+ int result = 17;
+ if (city != null) {
+ result = 31 * result + city.hashCode();
+ }
+ if (department != null) {
+ result = 31 * result + department.hashCode();
+ }
+ return result;
+ }
+
+}
diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Voucher.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Voucher.java
new file mode 100644
index 0000000000..19f46e0358
--- /dev/null
+++ b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/Voucher.java
@@ -0,0 +1,38 @@
+package com.baeldung.equalshashcode;
+
+class Voucher {
+
+ private Money value;
+ private String store;
+
+ Voucher(int amount, String currencyCode, String store) {
+ this.value = new Money(amount, currencyCode);
+ this.store = store;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof Voucher))
+ return false;
+ Voucher other = (Voucher)o;
+ boolean valueEquals = (this.value == null && other.value == null)
+ || (this.value != null && this.value.equals(other.value));
+ boolean storeEquals = (this.store == null && other.store == null)
+ || (this.store != null && this.store.equals(other.store));
+ return valueEquals && storeEquals;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ if (this.value != null) {
+ result = 31 * result + value.hashCode();
+ }
+ if (this.store != null) {
+ result = 31 * result + store.hashCode();
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongTeam.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongTeam.java
new file mode 100644
index 0000000000..c4477aa790
--- /dev/null
+++ b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongTeam.java
@@ -0,0 +1,30 @@
+package com.baeldung.equalshashcode;
+
+/* (non-Javadoc)
+* This class overrides equals, but it doesn't override hashCode.
+*
+* To see which problems this leads to:
+* TeamUnitTest.givenMapKeyWithoutHashCode_whenSearched_thenReturnsWrongValue
+*/
+class WrongTeam {
+
+ String city;
+ String department;
+
+ WrongTeam(String city, String department) {
+ this.city = city;
+ this.department = department;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof WrongTeam))
+ return false;
+ WrongTeam otherTeam = (WrongTeam)o;
+ return this.city == otherTeam.city
+ && this.department == otherTeam.department;
+ }
+
+}
diff --git a/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java
new file mode 100644
index 0000000000..97935bf8de
--- /dev/null
+++ b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java
@@ -0,0 +1,47 @@
+package com.baeldung.equalshashcode;
+
+/* (non-Javadoc)
+* This class extends the Money class that has overridden the equals method and once again overrides the equals method.
+*
+* To see which problems this leads to:
+* MoneyUnitTest.givenMoneyAndVoucherInstances_whenEquals_thenReturnValuesArentSymmetric
+*/
+class WrongVoucher extends Money {
+
+ private String store;
+
+ WrongVoucher(int amount, String currencyCode, String store) {
+ super(amount, currencyCode);
+
+ this.store = store;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof WrongVoucher))
+ return false;
+ WrongVoucher other = (WrongVoucher)o;
+ boolean currencyCodeEquals = (this.currencyCode == null && other.currencyCode == null)
+ || (this.currencyCode != null && this.currencyCode.equals(other.currencyCode));
+ boolean storeEquals = (this.store == null && other.store == null)
+ || (this.store != null && this.store.equals(other.store));
+ return this.amount == other.amount
+ && currencyCodeEquals
+ && storeEquals;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + amount;
+ if (this.currencyCode != null) {
+ result = 31 * result + currencyCode.hashCode();
+ }
+ if (this.store != null) {
+ result = 31 * result + store.hashCode();
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java
rename to core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java
diff --git a/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java
rename to core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java
diff --git a/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java
rename to core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java
diff --git a/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Shape.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Shape.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Shape.java
rename to core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Shape.java
diff --git a/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Square.java b/core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Square.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Square.java
rename to core-java-lang-oop/src/main/java/com/baeldung/equalshashcode/entities/Square.java
diff --git a/core-java-lang/src/main/java/com/baeldung/finalkeyword/BlackCat.java b/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/finalkeyword/BlackCat.java
rename to core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java
diff --git a/core-java-lang/src/main/java/com/baeldung/finalkeyword/BlackDog.java b/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/finalkeyword/BlackDog.java
rename to core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java
diff --git a/core-java-lang/src/main/java/com/baeldung/finalkeyword/Cat.java b/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/finalkeyword/Cat.java
rename to core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java
diff --git a/core-java-lang/src/main/java/com/baeldung/finalkeyword/Dog.java b/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/finalkeyword/Dog.java
rename to core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java
diff --git a/core-java-lang/src/main/java/com/baeldung/hashcode/entities/User.java b/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/hashcode/entities/User.java
rename to core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java
diff --git a/core-java-lang/src/main/java/com/baeldung/immutableobjects/Currency.java b/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Currency.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/immutableobjects/Currency.java
rename to core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Currency.java
diff --git a/core-java-lang/src/main/java/com/baeldung/immutableobjects/Money.java b/core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Money.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/immutableobjects/Money.java
rename to core-java-lang-oop/src/main/java/com/baeldung/immutableobjects/Money.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/ArmoredCar.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/ArmoredCar.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/BMW.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/BMW.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/Car.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/Car.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/Employee.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/Employee.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/Floatable.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/Floatable.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/Flyable.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/Flyable.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/SpaceCar.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/SpaceCar.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritance/SpaceTraveller.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritance/SpaceTraveller.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/application/Application.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/application/Application.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/application/Application.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/application/Application.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Person.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Person.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Person.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Person.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java
diff --git a/core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java b/core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java
rename to core-java-lang-oop/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java
diff --git a/core-java-lang/src/main/java/com/baeldung/initializationguide/User.java b/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/initializationguide/User.java
rename to core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java
diff --git a/core-java-lang/src/main/java/com/baeldung/keyword/KeywordDemo.java b/core-java-lang-oop/src/main/java/com/baeldung/keyword/KeywordDemo.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/keyword/KeywordDemo.java
rename to core-java-lang-oop/src/main/java/com/baeldung/keyword/KeywordDemo.java
diff --git a/core-java-lang/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java b/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java
rename to core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java
diff --git a/core-java-lang/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java b/core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java
rename to core-java-lang-oop/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java
diff --git a/core-java-lang/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java b/core-java-lang-oop/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java
rename to core-java-lang-oop/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java
diff --git a/core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java b/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java
rename to core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java
diff --git a/core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java b/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java
rename to core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java
diff --git a/core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java b/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java
rename to core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java
diff --git a/core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java b/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java
rename to core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java
diff --git a/core-java-lang/src/main/java/com/baeldung/polymorphism/FileManager.java b/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/polymorphism/FileManager.java
rename to core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java
diff --git a/core-java-lang/src/main/java/com/baeldung/polymorphism/GenericFile.java b/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/polymorphism/GenericFile.java
rename to core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java
diff --git a/core-java-lang/src/main/java/com/baeldung/polymorphism/ImageFile.java b/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/polymorphism/ImageFile.java
rename to core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java
diff --git a/core-java-lang/src/main/java/com/baeldung/polymorphism/TextFile.java b/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/polymorphism/TextFile.java
rename to core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java
diff --git a/core-java-lang/src/main/java/com/baeldung/scope/method/BaseMethodClass.java b/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/scope/method/BaseMethodClass.java
rename to core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java
diff --git a/core-java-lang/src/main/java/com/baeldung/scope/method/ChildMethodClass.java b/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/scope/method/ChildMethodClass.java
rename to core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java
diff --git a/core-java-lang/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java b/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java
rename to core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java
diff --git a/core-java-lang/src/main/java/com/baeldung/scope/variable/ChildVariable.java b/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/scope/variable/ChildVariable.java
rename to core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java
diff --git a/core-java-lang/src/main/java/com/baeldung/scope/variable/HideVariable.java b/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/scope/variable/HideVariable.java
rename to core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java
diff --git a/core-java-lang/src/main/java/com/baeldung/scope/variable/ParentVariable.java b/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/scope/variable/ParentVariable.java
rename to core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java
diff --git a/core-java-lang/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java b/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java
rename to core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java
diff --git a/core-java-lang/src/main/java/com/baeldung/staticdemo/Car.java b/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/staticdemo/Car.java
rename to core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java
diff --git a/core-java-lang/src/main/java/com/baeldung/staticdemo/Singleton.java b/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/staticdemo/Singleton.java
rename to core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java
diff --git a/core-java-lang/src/main/java/com/baeldung/staticdemo/StaticBlock.java b/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/staticdemo/StaticBlock.java
rename to core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java
diff --git a/core-java-lang/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java b/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java
rename to core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java
diff --git a/core-java-lang/src/main/java/com/baeldung/typeerasure/BoundStack.java b/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/typeerasure/BoundStack.java
rename to core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java
diff --git a/core-java-lang/src/main/java/com/baeldung/typeerasure/IntegerStack.java b/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/typeerasure/IntegerStack.java
rename to core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java
diff --git a/core-java-lang/src/main/java/com/baeldung/typeerasure/Stack.java b/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/typeerasure/Stack.java
rename to core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java
diff --git a/spring-rest-template/src/main/resources/logback.xml b/core-java-lang-oop/src/main/resources/logback.xml
similarity index 57%
rename from spring-rest-template/src/main/resources/logback.xml
rename to core-java-lang-oop/src/main/resources/logback.xml
index 7d900d8ea8..56af2d397e 100644
--- a/spring-rest-template/src/main/resources/logback.xml
+++ b/core-java-lang-oop/src/main/resources/logback.xml
@@ -7,6 +7,12 @@
+
+
+
+
+
+
diff --git a/core-java-lang/src/test/java/com/baeldung/casting/CastingUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/casting/CastingUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java
diff --git a/core-java/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java
diff --git a/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java
new file mode 100644
index 0000000000..60584fdb53
--- /dev/null
+++ b/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java
@@ -0,0 +1,27 @@
+package com.baeldung.equalshashcode;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+
+public class MoneyUnitTest {
+
+ @Test
+ public void givenMoneyInstancesWithSameAmountAndCurrency_whenEquals_thenReturnsTrue() {
+ Money income = new Money(55, "USD");
+ Money expenses = new Money(55, "USD");
+
+ assertTrue(income.equals(expenses));
+ }
+
+ @Test
+ public void givenMoneyAndVoucherInstances_whenEquals_thenReturnValuesArentSymmetric() {
+ Money cash = new Money(42, "USD");
+ WrongVoucher voucher = new WrongVoucher(42, "USD", "Amazon");
+
+ assertFalse(voucher.equals(cash));
+ assertTrue(cash.equals(voucher));
+ }
+
+}
diff --git a/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java
new file mode 100644
index 0000000000..a2de408796
--- /dev/null
+++ b/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java
@@ -0,0 +1,46 @@
+package com.baeldung.equalshashcode;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class TeamUnitTest {
+
+ @Test
+ public void givenMapKeyWithHashCode_whenSearched_thenReturnsCorrectValue() {
+ Map leaders = new HashMap<>();
+ leaders.put(new Team("New York", "development"), "Anne");
+ leaders.put(new Team("Boston", "development"), "Brian");
+ leaders.put(new Team("Boston", "marketing"), "Charlie");
+
+ Team myTeam = new Team("New York", "development");
+ String myTeamleader = leaders.get(myTeam);
+
+ assertEquals("Anne", myTeamleader);
+ }
+
+ @Test
+ public void givenMapKeyWithoutHashCode_whenSearched_thenReturnsWrongValue() {
+ Map leaders = new HashMap<>();
+ leaders.put(new WrongTeam("New York", "development"), "Anne");
+ leaders.put(new WrongTeam("Boston", "development"), "Brian");
+ leaders.put(new WrongTeam("Boston", "marketing"), "Charlie");
+
+ WrongTeam myTeam = new WrongTeam("New York", "development");
+ String myTeamleader = leaders.get(myTeam);
+
+ assertFalse("Anne".equals(myTeamleader));
+ }
+
+ @Test
+ public void equalsContract() {
+ EqualsVerifier.forClass(Team.class).verify();
+ }
+
+}
diff --git a/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/inheritance/AppUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/inheritance/AppUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/ActressUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/CompositionUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/InheritanceUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/PersonUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/inheritancecomposition/test/WaitressUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/initializationguide/UserUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/initializationguide/UserUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java b/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java b/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java b/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java b/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java
rename to core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java
diff --git a/core-java-lang-oop/src/test/resources/.gitignore b/core-java-lang-oop/src/test/resources/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/core-java-lang-oop/src/test/resources/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/core-java-lang-syntax/.gitignore b/core-java-lang-syntax/.gitignore
new file mode 100644
index 0000000000..374c8bf907
--- /dev/null
+++ b/core-java-lang-syntax/.gitignore
@@ -0,0 +1,25 @@
+*.class
+
+0.*
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+.resourceCache
+
+# Packaged files #
+*.jar
+*.war
+*.ear
+
+# Files generated by integration tests
+backup-pom.xml
+/bin/
+/temp
+
+#IntelliJ specific
+.idea/
+*.iml
\ No newline at end of file
diff --git a/core-java-lang-syntax/README.md b/core-java-lang-syntax/README.md
new file mode 100644
index 0000000000..a7c1b7cc4a
--- /dev/null
+++ b/core-java-lang-syntax/README.md
@@ -0,0 +1,19 @@
+=========
+
+## Core Java Lang Syntax Cookbooks and Examples
+
+### Relevant Articles:
+- [Introduction to Java Generics](http://www.baeldung.com/java-generics)
+- [Java Primitive Conversions](http://www.baeldung.com/java-primitive-conversions)
+- [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization)
+- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator)
+- [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break)
+- [A Guide to Java Initialization](http://www.baeldung.com/java-initialization)
+- [A Guide to Java Loops](http://www.baeldung.com/java-loops)
+- [Varargs in Java](http://www.baeldung.com/java-varargs)
+- [A Guide to Java Enums](http://www.baeldung.com/a-guide-to-java-enums)
+- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
+- [Quick Guide to java.lang.System](http://www.baeldung.com/java-lang-system)
+- [Java Switch Statement](https://www.baeldung.com/java-switch)
+- [The Modulo Operator in Java](https://www.baeldung.com/modulo-java)
+- [Ternary Operator In Java](https://www.baeldung.com/java-ternary-operator)
\ No newline at end of file
diff --git a/core-java-lang-syntax/pom.xml b/core-java-lang-syntax/pom.xml
new file mode 100644
index 0000000000..9481f29459
--- /dev/null
+++ b/core-java-lang-syntax/pom.xml
@@ -0,0 +1,53 @@
+
+ 4.0.0
+ com.baeldung
+ core-java-lang-syntax
+ 0.1.0-SNAPSHOT
+ jar
+ core-java-lang-syntax
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+ org.slf4j
+ log4j-over-slf4j
+ ${org.slf4j.version}
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+
+
+ core-java-lang-syntax
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ 3.10.0
+
+
+
diff --git a/core-java-lang/src/main/java/com/baeldung/breakcontinue/BreakContinue.java b/core-java-lang-syntax/src/main/java/com/baeldung/breakcontinue/BreakContinue.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/breakcontinue/BreakContinue.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/breakcontinue/BreakContinue.java
diff --git a/core-java-lang/src/main/java/com/baeldung/enums/Pizza.java b/core-java-lang-syntax/src/main/java/com/baeldung/enums/Pizza.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/enums/Pizza.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/enums/Pizza.java
diff --git a/core-java-lang/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java b/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliveryStrategy.java
diff --git a/core-java-lang/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java b/core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/enums/PizzaDeliverySystemConfiguration.java
diff --git a/core-java-lang/src/main/java/com/baeldung/enums/README.md b/core-java-lang-syntax/src/main/java/com/baeldung/enums/README.md
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/enums/README.md
rename to core-java-lang-syntax/src/main/java/com/baeldung/enums/README.md
diff --git a/core-java-lang/src/main/java/com/baeldung/generics/Building.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/generics/Building.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/generics/Building.java
diff --git a/core-java-lang/src/main/java/com/baeldung/generics/Generics.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/generics/Generics.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/generics/Generics.java
diff --git a/core-java-lang/src/main/java/com/baeldung/generics/House.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/generics/House.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/generics/House.java
diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java b/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java
new file mode 100644
index 0000000000..e2e3f051dd
--- /dev/null
+++ b/core-java-lang-syntax/src/main/java/com/baeldung/initializationguide/User.java
@@ -0,0 +1,53 @@
+package com.baeldung.initializationguide;
+
+import java.io.Serializable;
+
+public class User implements Serializable, Cloneable {
+ private static final long serialVersionUID = 1L;
+ static String forum;
+ private String name;
+ private int id;
+
+ {
+ id = 0;
+ System.out.println("Instance Initializer");
+ }
+
+ static {
+ forum = "Java";
+ System.out.println("Static Initializer");
+ }
+
+ public User(String name, int id) {
+ super();
+ this.name = name;
+ this.id = id;
+ }
+
+ public User() {
+ System.out.println("Constructor");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ return this;
+ }
+
+}
+
diff --git a/core-java-lang/src/main/java/com/baeldung/loops/InfiniteLoops.java b/core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/loops/InfiniteLoops.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/loops/InfiniteLoops.java
diff --git a/core-java-lang/src/main/java/com/baeldung/loops/LoopsInJava.java b/core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/loops/LoopsInJava.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/loops/LoopsInJava.java
diff --git a/core-java-lang/src/main/java/com/baeldung/switchstatement/SwitchStatement.java b/core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/switchstatement/SwitchStatement.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/switchstatement/SwitchStatement.java
diff --git a/core-java-lang/src/main/java/com/baeldung/system/ChatWindow.java b/core-java-lang-syntax/src/main/java/com/baeldung/system/ChatWindow.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/system/ChatWindow.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/system/ChatWindow.java
diff --git a/core-java-lang/src/main/java/com/baeldung/system/DateTimeService.java b/core-java-lang-syntax/src/main/java/com/baeldung/system/DateTimeService.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/system/DateTimeService.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/system/DateTimeService.java
diff --git a/core-java-lang/src/main/java/com/baeldung/system/EnvironmentVariables.java b/core-java-lang-syntax/src/main/java/com/baeldung/system/EnvironmentVariables.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/system/EnvironmentVariables.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/system/EnvironmentVariables.java
diff --git a/core-java-lang/src/main/java/com/baeldung/system/SystemErrDemo.java b/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemErrDemo.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/system/SystemErrDemo.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/system/SystemErrDemo.java
diff --git a/core-java-lang/src/main/java/com/baeldung/system/SystemExitDemo.java b/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemExitDemo.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/system/SystemExitDemo.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/system/SystemExitDemo.java
diff --git a/core-java-lang/src/main/java/com/baeldung/system/SystemOutDemo.java b/core-java-lang-syntax/src/main/java/com/baeldung/system/SystemOutDemo.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/system/SystemOutDemo.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/system/SystemOutDemo.java
diff --git a/core-java-lang/src/main/java/com/baeldung/system/UserCredentials.java b/core-java-lang-syntax/src/main/java/com/baeldung/system/UserCredentials.java
similarity index 100%
rename from core-java-lang/src/main/java/com/baeldung/system/UserCredentials.java
rename to core-java-lang-syntax/src/main/java/com/baeldung/system/UserCredentials.java
diff --git a/core-java-lang/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/breakcontinue/BreakContinueUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/enums/PizzaUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/enums/PizzaUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/enums/PizzaUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/enums/PizzaUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/generics/GenericsUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/generics/GenericsUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericsUnitTest.java
diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java
new file mode 100644
index 0000000000..f74384e6f7
--- /dev/null
+++ b/core-java-lang-syntax/src/test/java/com/baeldung/initializationguide/UserUnitTest.java
@@ -0,0 +1,37 @@
+package com.baeldung.initializationguide;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class UserUnitTest {
+
+ @Test
+ public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() {
+ User user = new User("Alice", 1);
+ assertThat(user).isNotNull();
+ }
+
+ @Test
+ public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ User user = User.class.getConstructor(String.class, int.class)
+ .newInstance("Alice", 2);
+ assertThat(user).isNotNull();
+ }
+
+ @Test
+ public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException {
+ User user = new User("Alice", 3);
+ User clonedUser = (User) user.clone();
+ assertThat(clonedUser).isEqualTo(user);
+ }
+
+ @Test
+ public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() {
+ User user = new User();
+ assertThat(user.getName()).isNull();
+ assertThat(user.getId() == 0);
+ }
+}
diff --git a/core-java-lang/src/test/java/com/baeldung/java/diamond/Car.java b/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Car.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/java/diamond/Car.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Car.java
diff --git a/core-java-lang/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/DiamondOperatorUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/java/diamond/Diesel.java b/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Diesel.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/java/diamond/Diesel.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Diesel.java
diff --git a/core-java-lang/src/test/java/com/baeldung/java/diamond/Engine.java b/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Engine.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/java/diamond/Engine.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Engine.java
diff --git a/core-java-lang/src/test/java/com/baeldung/java/diamond/Vehicle.java b/core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Vehicle.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/java/diamond/Vehicle.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/java/diamond/Vehicle.java
diff --git a/core-java-lang/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/java/doublebrace/DoubleBraceUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/loops/WhenUsingLoops.java b/core-java-lang-syntax/src/test/java/com/baeldung/loops/WhenUsingLoops.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/loops/WhenUsingLoops.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/loops/WhenUsingLoops.java
diff --git a/core-java-lang/src/test/java/com/baeldung/modulo/ModuloUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/modulo/ModuloUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/modulo/ModuloUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/modulo/ModuloUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/primitiveconversion/PrimitiveConversionsJUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/switchstatement/SwitchStatementUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/system/DateTimeServiceUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/system/EnvironmentVariablesUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/system/SystemArrayCopyUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/system/SystemNanoUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemNanoUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/system/SystemNanoUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/system/SystemNanoUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/system/SystemPropertiesUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/varargs/FormatterUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/varargs/FormatterUnitTest.java
similarity index 100%
rename from core-java-lang/src/test/java/com/baeldung/varargs/FormatterUnitTest.java
rename to core-java-lang-syntax/src/test/java/com/baeldung/varargs/FormatterUnitTest.java
diff --git a/core-java-lang/README.md b/core-java-lang/README.md
index 85312cba68..52dfe708a3 100644
--- a/core-java-lang/README.md
+++ b/core-java-lang/README.md
@@ -4,44 +4,24 @@
### Relevant Articles:
- [Guide to Java Reflection](http://www.baeldung.com/java-reflection)
-- [Introduction to Java Generics](http://www.baeldung.com/java-generics)
- [Generate equals() and hashCode() with Eclipse](http://www.baeldung.com/java-eclipse-equals-and-hashcode)
- [Chained Exceptions in Java](http://www.baeldung.com/java-chained-exceptions)
-- [Java Primitive Conversions](http://www.baeldung.com/java-primitive-conversions)
- [Call Methods at Runtime Using Java Reflection](http://www.baeldung.com/java-method-reflection)
- [Iterating Over Enum Values in Java](http://www.baeldung.com/java-enum-iteration)
- [Changing Annotation Parameters At Runtime](http://www.baeldung.com/java-reflection-change-annotation-params)
- [Dynamic Proxies in Java](http://www.baeldung.com/java-dynamic-proxies)
- [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization)
-- [Guide to hashCode() in Java](http://www.baeldung.com/java-hashcode)
- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator)
-- [A Guide to the Static Keyword in Java](http://www.baeldung.com/java-static)
- [Quick Example - Comparator vs Comparable in Java](http://www.baeldung.com/java-comparator-comparable)
- [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break)
-- [A Guide to Java Initialization](http://www.baeldung.com/java-initialization)
- [Nested Classes in Java](http://www.baeldung.com/java-nested-classes)
-- [A Guide to Java Loops](http://www.baeldung.com/java-loops)
-- [Varargs in Java](http://www.baeldung.com/java-varargs)
- [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces)
-- [Polymorphism in Java](http://www.baeldung.com/java-polymorphism)
- [Recursion In Java](http://www.baeldung.com/java-recursion)
- [A Guide to the finalize Method in Java](http://www.baeldung.com/java-finalize)
-- [Method Overloading and Overriding in Java](http://www.baeldung.com/java-method-overload-override)
-- [How to Make a Deep Copy of an Object in Java](http://www.baeldung.com/java-deep-copy)
-- [Guide to Inheritance in Java](http://www.baeldung.com/java-inheritance)
-- [Object Type Casting in Java](http://www.baeldung.com/java-type-casting)
-- [The "final" Keyword in Java](http://www.baeldung.com/java-final)
- [A Guide to Java Enums](http://www.baeldung.com/a-guide-to-java-enums)
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
- [Quick Guide to java.lang.System](http://www.baeldung.com/java-lang-system)
-- [Type Erasure in Java Explained](http://www.baeldung.com/java-type-erasure)
- [Using Java Assertions](http://www.baeldung.com/java-assert)
-- [Pass-By-Value as a Parameter Passing Mechanism in Java](http://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
-- [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding)
-- [Access Modifiers in Java](http://www.baeldung.com/java-access-modifiers)
-- [Guide to the super Java Keyword](http://www.baeldung.com/java-super)
-- [Guide to the this Java Keyword](http://www.baeldung.com/java-this)
-- [Immutable Objects in Java](http://www.baeldung.com/java-immutable-object)
- [ClassNotFoundException vs NoClassDefFoundError](http://www.baeldung.com/java-classnotfoundexception-and-noclassdeffounderror)
- [The StackOverflowError in Java](http://www.baeldung.com/java-stack-overflow-error)
- [Create a Custom Exception in Java](http://www.baeldung.com/java-new-custom-exception)
@@ -50,10 +30,6 @@
- [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding)
- [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws)
- [Synthetic Constructs in Java](https://www.baeldung.com/java-synthetic)
-- [Java Switch Statement](https://www.baeldung.com/java-switch)
-- [The Modulo Operator in Java](https://www.baeldung.com/modulo-java)
-- [Ternary Operator In Java](https://www.baeldung.com/java-ternary-operator)
- [How to Separate Double into Integer and Decimal Parts](https://www.baeldung.com/java-separate-double-into-integer-decimal-parts)
- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws)
-- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](http://www.baeldung.com/java-inheritance-composition)
-
+- [Retrieving a Class Name in Java](https://www.baeldung.com/java-class-name)
diff --git a/core-java-lang/native/nativedatetimeutils.dll b/core-java-lang/native/nativedatetimeutils.dll
new file mode 100644
index 0000000000..ecdd388380
Binary files /dev/null and b/core-java-lang/native/nativedatetimeutils.dll differ
diff --git a/core-java-lang/pom.xml b/core-java-lang/pom.xml
index ace39de274..283acab775 100644
--- a/core-java-lang/pom.xml
+++ b/core-java-lang/pom.xml
@@ -56,11 +56,6 @@
${assertj-core.version}test
-
- org.springframework
- spring-web
- ${springframework.spring-web.version}
- javax.mailmail
@@ -76,334 +71,12 @@
true
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*LiveTest.java
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
-
- true
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy-dependencies
- prepare-package
-
- copy-dependencies
-
-
- ${project.build.directory}/libs
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- ${maven-jar-plugin.version}
-
-
-
- true
- libs/
- org.baeldung.executable.ExecutableMavenJar
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
-
-
- package
-
- single
-
-
- ${project.basedir}
-
-
- org.baeldung.executable.ExecutableMavenJar
-
-
-
- jar-with-dependencies
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- ${maven-shade-plugin.version}
-
-
-
- shade
-
-
- true
-
-
- org.baeldung.executable.ExecutableMavenJar
-
-
-
-
-
-
-
-
- com.jolira
- onejar-maven-plugin
- ${onejar-maven-plugin.version}
-
-
-
- org.baeldung.executable.ExecutableMavenJar
- true
- ${project.build.finalName}-onejar.${project.packaging}
-
-
- one-jar
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- ${spring-boot-maven-plugin.version}
-
-
-
- repackage
-
-
- spring-boot
- org.baeldung.executable.ExecutableMavenJar
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- ${exec-maven-plugin.version}
-
- java
- com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
-
- -Xmx300m
- -XX:+UseParallelGC
- -classpath
-
- com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- ${maven-javadoc-plugin.version}
-
-
- 1.8
-
-
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*ManualTest.java
-
-
- **/*IntegrationTest.java
- **/*IntTest.java
-
-
-
-
-
-
- json
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- ${exec-maven-plugin.version}
-
-
- run-benchmarks
-
- none
-
- exec
-
-
- test
- java
-
- -classpath
-
- org.openjdk.jmh.Main
- .*
-
-
-
-
-
-
-
-
-
-
-
- buildAgentLoader
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- package
-
- jar
-
-
- agentLoader
- target/classes
-
-
- true
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
-
- com/baeldung/instrumentation/application/AgentLoader.class
- com/baeldung/instrumentation/application/Launcher.class
-
-
-
-
-
-
-
-
-
- buildApplication
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- package
-
- jar
-
-
- application
- target/classes
-
-
- true
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
-
- com/baeldung/instrumentation/application/MyAtm.class
- com/baeldung/instrumentation/application/MyAtmApplication.class
- com/baeldung/instrumentation/application/Launcher.class
-
-
-
-
-
-
-
-
-
- buildAgent
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- package
-
- jar
-
-
- agent
- target/classes
-
-
- true
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
-
- com/baeldung/instrumentation/agent/AtmTransformer.class
- com/baeldung/instrumentation/agent/MyInstrumentationAgent.class
-
-
-
-
-
-
-
-
-
-
- 2.8.5
+ 2.9.72.8.2
@@ -414,16 +87,6 @@
3.10.0
-
-
- 2.21.0
- 4.3.4.RELEASE
- 3.0.0-M1
- 3.0.2
- 1.4.4
- 3.1.1
- 2.0.3.RELEASE
- 1.6.0
diff --git a/core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java b/core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java
new file mode 100644
index 0000000000..ab6c8a51ff
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java
@@ -0,0 +1,9 @@
+package com.baeldung.className;
+
+public class RetrievingClassName {
+
+ public class InnerClass {
+
+ }
+
+}
diff --git a/core-java-lang/src/main/java/com/baeldung/controlstructures/ConditionalBranches.java b/core-java-lang/src/main/java/com/baeldung/controlstructures/ConditionalBranches.java
new file mode 100644
index 0000000000..bace609699
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/controlstructures/ConditionalBranches.java
@@ -0,0 +1,68 @@
+package com.baeldung.controlstructures;
+
+public class ConditionalBranches {
+
+ /**
+ * Multiple if/else/else if statements examples. Shows different syntax usage.
+ */
+ public static void ifElseStatementsExamples() {
+ int count = 2; // Initial count value.
+
+ // Basic syntax. Only one statement follows. No brace usage.
+ if (count > 1)
+ System.out.println("Count is higher than 1");
+
+ // Basic syntax. More than one statement can be included. Braces are used (recommended syntax).
+ if (count > 1) {
+ System.out.println("Count is higher than 1");
+ System.out.println("Count is equal to: " + count);
+ }
+
+ // If/Else syntax. Two different courses of action can be included.
+ if (count > 2) {
+ System.out.println("Count is higher than 2");
+ } else {
+ System.out.println("Count is lower or equal than 2");
+ }
+
+ // If/Else/Else If syntax. Three or more courses of action can be included.
+ if (count > 2) {
+ System.out.println("Count is higher than 2");
+ } else if (count <= 0) {
+ System.out.println("Count is less or equal than zero");
+ } else {
+ System.out.println("Count is either equal to one, or two");
+ }
+ }
+
+ /**
+ * Ternary Operator example.
+ * @see ConditionalBranches#ifElseStatementsExamples()
+ */
+ public static void ternaryExample() {
+ int count = 2;
+ System.out.println(count > 2 ? "Count is higher than 2" : "Count is lower or equal than 2");
+ }
+
+ /**
+ * Switch structure example. Shows how to replace multiple if/else statements with one structure.
+ */
+ public static void switchExample() {
+ int count = 3;
+ switch (count) {
+ case 0:
+ System.out.println("Count is equal to 0");
+ break;
+ case 1:
+ System.out.println("Count is equal to 1");
+ break;
+ case 2:
+ System.out.println("Count is equal to 2");
+ break;
+ default:
+ System.out.println("Count is either negative, or higher than 2");
+ break;
+ }
+ }
+
+}
diff --git a/core-java-lang/src/main/java/com/baeldung/controlstructures/Loops.java b/core-java-lang/src/main/java/com/baeldung/controlstructures/Loops.java
new file mode 100644
index 0000000000..bc4515bfc7
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/controlstructures/Loops.java
@@ -0,0 +1,157 @@
+package com.baeldung.controlstructures;
+
+public class Loops {
+
+ /**
+ * Dummy method. Only prints a generic message.
+ */
+ private static void methodToRepeat() {
+ System.out.println("Dummy method.");
+ }
+
+ /**
+ * Shows how to iterate 50 times with 3 different method/control structures.
+ */
+ public static void repetitionTo50Examples() {
+ for (int i = 1; i <= 50; i++) {
+ methodToRepeat();
+ }
+
+ int whileCounter = 1;
+ while (whileCounter <= 50) {
+ methodToRepeat();
+ whileCounter++;
+ }
+
+ int count = 1;
+ do {
+ methodToRepeat();
+ count++;
+ } while (count < 50);
+ }
+
+ /**
+ * Splits a sentence in words, and prints each word in a new line.
+ * @param sentence Sentence to print as independent words.
+ */
+ public static void printWordByWord(String sentence) {
+ for (String word : sentence.split(" ")) {
+ System.out.println(word);
+ }
+ }
+
+ /**
+ * Prints text an N amount of times. Shows usage of the {@code break} branching statement.
+ * @param textToPrint Text to repeatedly print.
+ * @param times Amount to times to print received text.
+ */
+ public static void printTextNTimes(String textToPrint, int times) {
+ int counter = 1;
+ while (true) {
+ System.out.println(textToPrint);
+ if (counter == times) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Prints text an N amount of times, up to 50. Shows usage of the {@code break} branching statement.
+ * @param textToPrint Text to repeatedly print.
+ * @param times Amount to times to print received text. If times is higher than 50, textToPrint will only be printed 50 times.
+ */
+ public static void printTextNTimesUpTo50(String textToPrint, int times) {
+ int counter = 1;
+ while (counter < 50) {
+ System.out.println(textToPrint);
+ if (counter == times) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Finds the index of {@code name} in a list
+ * @param name The name to look for
+ * @param names The list of names
+ * @return The index where the name was found or -1 otherwise
+ */
+ public static int findFirstInstanceOfName(String name, String[] names) {
+ int index = 0;
+ for ( ; index < names.length; index++) {
+ if (names[index].equals(name)) {
+ break;
+ }
+ }
+ return index == names.length ? -1 : index;
+ }
+
+ /**
+ * Takes several names and makes a list, skipping the specified {@code name}.
+ *
+ * @param name The name to skip
+ * @param names The list of names
+ * @return The list of names as a single string, missing the specified {@code name}.
+ */
+ public static String makeListSkippingName(String name, String[] names) {
+ String list = "";
+ for (int i = 0; i < names.length; i++) {
+ if (names[i].equals(name)) {
+ continue;
+ }
+ list += names[i];
+ }
+ return list;
+ }
+
+ /**
+ * Prints an specified amount of even numbers. Shows usage of both {@code break} and {@code continue} branching statements.
+ * @param amountToPrint Amount of even numbers to print.
+ */
+ public static void printEvenNumbers(int amountToPrint) {
+ if (amountToPrint <= 0) { // Invalid input
+ return;
+ }
+ int iterator = 0;
+ int amountPrinted = 0;
+ while (true) {
+ if (iterator % 2 == 0) { // Is an even number
+ System.out.println(iterator);
+ amountPrinted++;
+ iterator++;
+ } else {
+ iterator++;
+ continue; // Won't print
+ }
+ if (amountPrinted == amountToPrint) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Prints an specified amount of even numbers, up to 100. Shows usage of both {@code break} and {@code continue} branching statements.
+ * @param amountToPrint Amount of even numbers to print.
+ */
+ public static void printEvenNumbersToAMaxOf100(int amountToPrint) {
+ if (amountToPrint <= 0) { // Invalid input
+ return;
+ }
+ int iterator = 0;
+ int amountPrinted = 0;
+ while (amountPrinted < 100) {
+ if (iterator % 2 == 0) { // Is an even number
+ System.out.println(iterator);
+ amountPrinted++;
+ iterator++;
+ } else {
+ iterator++;
+ continue; // Won't print
+ }
+ if (amountPrinted == amountToPrint) {
+ break;
+ }
+ }
+ }
+
+}
diff --git a/core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java b/core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java
new file mode 100644
index 0000000000..0762b0eb8a
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java
@@ -0,0 +1,10 @@
+package com.baeldung.nativekeyword;
+
+public class DateTimeUtils {
+
+ public native String getSystemTime();
+
+ static {
+ System.loadLibrary("nativedatetimeutils");
+ }
+}
diff --git a/core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java b/core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java
new file mode 100644
index 0000000000..76fe548ed3
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java
@@ -0,0 +1,11 @@
+package com.baeldung.nativekeyword;
+
+import com.baeldung.nativekeyword.DateTimeUtils;
+
+public class NativeMainApp {
+ public static void main(String[] args) {
+ DateTimeUtils dateTimeUtils = new DateTimeUtils();
+ String input = dateTimeUtils.getSystemTime();
+ System.out.println("System time is : " + input);
+ }
+}
diff --git a/core-java-lang/src/main/java/com/baeldung/packages/TodoApp.java b/core-java-lang/src/main/java/com/baeldung/packages/TodoApp.java
new file mode 100644
index 0000000000..0f4a56f708
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/packages/TodoApp.java
@@ -0,0 +1,22 @@
+package com.baeldung.packages;
+
+import java.time.LocalDate;
+
+import com.baeldung.packages.domain.TodoItem;
+
+public class TodoApp {
+
+ public static void main(String[] args) {
+ TodoList todoList = new TodoList();
+ for (int i = 0; i < 3; i++) {
+ TodoItem item = new TodoItem();
+ item.setId(Long.valueOf((long)i));
+ item.setDescription("Todo item " + (i + 1));
+ item.setDueDate(LocalDate.now().plusDays((long)(i + 1)));
+ todoList.addTodoItem(item);
+ }
+
+ todoList.getTodoItems().forEach((TodoItem todoItem) -> System.out.println(todoItem.toString()));
+ }
+
+}
diff --git a/core-java-lang/src/main/java/com/baeldung/packages/TodoList.java b/core-java-lang/src/main/java/com/baeldung/packages/TodoList.java
new file mode 100644
index 0000000000..6ed6cd4ec1
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/packages/TodoList.java
@@ -0,0 +1,27 @@
+package com.baeldung.packages;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.baeldung.packages.domain.TodoItem;
+
+public class TodoList {
+ private List todoItems;
+
+ public void addTodoItem(TodoItem todoItem) {
+ if (todoItems == null) {
+ todoItems = new ArrayList();
+ }
+
+ todoItems.add(todoItem);
+ }
+
+ public List getTodoItems() {
+ return todoItems;
+ }
+
+ public void setTodoItems(List todoItems) {
+ this.todoItems = todoItems;
+ }
+
+}
diff --git a/core-java-lang/src/main/java/com/baeldung/packages/domain/TodoItem.java b/core-java-lang/src/main/java/com/baeldung/packages/domain/TodoItem.java
new file mode 100644
index 0000000000..972e574a7f
--- /dev/null
+++ b/core-java-lang/src/main/java/com/baeldung/packages/domain/TodoItem.java
@@ -0,0 +1,39 @@
+package com.baeldung.packages.domain;
+
+import java.time.LocalDate;
+
+public class TodoItem {
+ private Long id;
+ private String description;
+ private LocalDate dueDate;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public LocalDate getDueDate() {
+ return dueDate;
+ }
+
+ public void setDueDate(LocalDate dueDate) {
+ this.dueDate = dueDate;
+ }
+
+ @Override
+ public String toString() {
+ return "TodoItem [id=" + id + ", description=" + description + ", dueDate=" + dueDate + "]";
+ }
+
+}
diff --git a/core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java b/core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java
new file mode 100644
index 0000000000..f9dbf91d2c
--- /dev/null
+++ b/core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java
@@ -0,0 +1,156 @@
+package com.baeldung.className;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class RetrievingClassNameUnitTest {
+
+ // Retrieving Simple Name
+ @Test
+ public void givenRetrievingClassName_whenGetSimpleName_thenRetrievingClassName() {
+ assertEquals("RetrievingClassName", RetrievingClassName.class.getSimpleName());
+ }
+
+ @Test
+ public void givenPrimitiveInt_whenGetSimpleName_thenInt() {
+ assertEquals("int", int.class.getSimpleName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetSimpleName_thenRetrievingClassNameWithBrackets() {
+ assertEquals("RetrievingClassName[]", RetrievingClassName[].class.getSimpleName());
+ assertEquals("RetrievingClassName[][]", RetrievingClassName[][].class.getSimpleName());
+ }
+
+ @Test
+ public void givenAnonymousClass_whenGetSimpleName_thenEmptyString() {
+ assertEquals("", new RetrievingClassName() {}.getClass().getSimpleName());
+ }
+
+ // Retrieving Other Names
+ // - Primitive Types
+ @Test
+ public void givenPrimitiveInt_whenGetName_thenInt() {
+ assertEquals("int", int.class.getName());
+ }
+
+ @Test
+ public void givenPrimitiveInt_whenGetTypeName_thenInt() {
+ assertEquals("int", int.class.getTypeName());
+ }
+
+ @Test
+ public void givenPrimitiveInt_whenGetCanonicalName_thenInt() {
+ assertEquals("int", int.class.getCanonicalName());
+ }
+
+ // - Object Types
+ @Test
+ public void givenRetrievingClassName_whenGetName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName", RetrievingClassName.class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassName_whenGetTypeName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName", RetrievingClassName.class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassName_whenGetCanonicalName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName", RetrievingClassName.class.getCanonicalName());
+ }
+
+ // - Inner Classes
+ @Test
+ public void givenRetrievingClassNameInnerClass_whenGetName_thenCanonicalNameWithDollarSeparator() {
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass", RetrievingClassName.InnerClass.class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClass_whenGetTypeName_thenCanonicalNameWithDollarSeparator() {
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass", RetrievingClassName.InnerClass.class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClass_whenGetCanonicalName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName.InnerClass", RetrievingClassName.InnerClass.class.getCanonicalName());
+ }
+
+ // - Anonymous Classes
+ @Test
+ public void givenAnonymousClass_whenGetName_thenCallingClassCanonicalNameWithDollarSeparatorAndCountNumber() {
+ // These are the second and third appearences of an anonymous class in RetrievingClassNameUnitTest, hence $2 and $3 expectations
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$2", new RetrievingClassName() {}.getClass().getName());
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$3", new RetrievingClassName() {}.getClass().getName());
+ }
+
+ @Test
+ public void givenAnonymousClass_whenGetTypeName_thenCallingClassCanonicalNameWithDollarSeparatorAndCountNumber() {
+ // These are the fourth and fifth appearences of an anonymous class in RetrievingClassNameUnitTest, hence $4 and $5 expectations
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$4", new RetrievingClassName() {}.getClass().getTypeName());
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$5", new RetrievingClassName() {}.getClass().getTypeName());
+ }
+
+ @Test
+ public void givenAnonymousClass_whenGetCanonicalName_thenNull() {
+ assertNull(new RetrievingClassName() {}.getClass().getCanonicalName());
+ }
+
+ // - Arrays
+ @Test
+ public void givenPrimitiveIntArray_whenGetName_thenOpeningBracketsAndPrimitiveIntLetter() {
+ assertEquals("[I", int[].class.getName());
+ assertEquals("[[I", int[][].class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetName_thenOpeningBracketsLetterLAndRetrievingClassNameGetName() {
+ assertEquals("[Lcom.baeldung.className.RetrievingClassName;", RetrievingClassName[].class.getName());
+ assertEquals("[[Lcom.baeldung.className.RetrievingClassName;", RetrievingClassName[][].class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClassArray_whenGetName_thenOpeningBracketsLetterLAndRetrievingClassNameInnerClassGetName() {
+ assertEquals("[Lcom.baeldung.className.RetrievingClassName$InnerClass;", RetrievingClassName.InnerClass[].class.getName());
+ assertEquals("[[Lcom.baeldung.className.RetrievingClassName$InnerClass;", RetrievingClassName.InnerClass[][].class.getName());
+ }
+
+ @Test
+ public void givenPrimitiveIntArray_whenGetTypeName_thenPrimitiveIntGetTypeNameWithBrackets() {
+ assertEquals("int[]", int[].class.getTypeName());
+ assertEquals("int[][]", int[][].class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetTypeName_thenRetrievingClassNameGetTypeNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName[]", RetrievingClassName[].class.getTypeName());
+ assertEquals("com.baeldung.className.RetrievingClassName[][]", RetrievingClassName[][].class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClassArray_whenGetTypeName_thenRetrievingClassNameInnerClassGetTypeNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass[]", RetrievingClassName.InnerClass[].class.getTypeName());
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass[][]", RetrievingClassName.InnerClass[][].class.getTypeName());
+ }
+
+ @Test
+ public void givenPrimitiveIntArray_whenGetCanonicalName_thenPrimitiveIntGetCanonicalNameWithBrackets() {
+ assertEquals("int[]", int[].class.getCanonicalName());
+ assertEquals("int[][]", int[][].class.getCanonicalName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetCanonicalName_thenRetrievingClassNameGetCanonicalNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName[]", RetrievingClassName[].class.getCanonicalName());
+ assertEquals("com.baeldung.className.RetrievingClassName[][]", RetrievingClassName[][].class.getCanonicalName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClassArray_whenGetCanonicalName_thenRetrievingClassNameInnerClassGetCanonicalNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName.InnerClass[]", RetrievingClassName.InnerClass[].class.getCanonicalName());
+ assertEquals("com.baeldung.className.RetrievingClassName.InnerClass[][]", RetrievingClassName.InnerClass[][].class.getCanonicalName());
+ }
+
+}
\ No newline at end of file
diff --git a/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java b/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java
new file mode 100644
index 0000000000..532776edd4
--- /dev/null
+++ b/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java
@@ -0,0 +1,111 @@
+package com.baeldung.compoundoperators;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class CompoundOperatorsUnitTest {
+
+ @Test
+ public void whenAssignmentOperatorIsUsed_thenValueIsAssigned() {
+ int x = 5;
+
+ assertEquals(5, x);
+ }
+
+ @Test
+ public void whenCompoundAssignmentUsed_thenSameAsSimpleAssignment() {
+ int a = 3, b = 3, c = -2;
+ a = a * c; // Simple assignment operator
+ b *= c; // Compound assignment operator
+
+ assertEquals(a, b);
+ }
+
+ @Test
+ public void whenAssignmentOperatorIsUsed_thenValueIsReturned() {
+ long x = 1;
+ long y = (x+=2);
+
+ assertEquals(3, y);
+ assertEquals(y, x);
+ }
+
+ @Test
+ public void whenCompoundOperatorsAreUsed_thenOperationsArePerformedAndAssigned() {
+ //Simple assignment
+ int x = 5; //x is 5
+
+ //Incrementation
+ x += 5; //x is 10
+ assertEquals(10, x);
+
+ //Decrementation
+ x -= 2; //x is 8
+ assertEquals(8, x);
+
+ //Multiplication
+ x *= 2; //x is 16
+ assertEquals(16, x);
+
+ //Division
+ x /= 4; //x is 4
+ assertEquals(4, x);
+
+ //Modulus
+ x %= 3; //x is 1
+ assertEquals(1, x);
+
+
+ //Binary AND
+ x &= 4; //x is 0
+ assertEquals(0, x);
+
+ //Binary exclusive OR
+ x ^= 4; //x is 4
+ assertEquals(4, x);
+
+ //Binary inclusive OR
+ x |= 8; //x is 12
+ assertEquals(12, x);
+
+
+ //Binary Left Shift
+ x <<= 2; //x is 48
+ assertEquals(48, x);
+
+ //Binary Right Shift
+ x >>= 2; //x is 12
+ assertEquals(12, x);
+
+ //Shift right zero fill
+ x >>>= 1; //x is 6
+ assertEquals(6, x);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void whenArrayIsNull_thenThrowNullException() {
+ int[] numbers = null;
+
+ //Trying Incrementation
+ numbers[2] += 5;
+ }
+
+ @Test(expected = ArrayIndexOutOfBoundsException.class)
+ public void whenArrayIndexNotCorrect_thenThrowArrayIndexException() {
+ int[] numbers = {0, 1};
+
+ //Trying Incrementation
+ numbers[2] += 5;
+ }
+
+ @Test
+ public void whenArrayIndexIsCorrect_thenPerformOperation() {
+ int[] numbers = {0, 1};
+
+ //Incrementation
+ numbers[1] += 5;
+ assertEquals(6, numbers[1]);
+ }
+
+}
diff --git a/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java b/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java
new file mode 100644
index 0000000000..d5003dfc1f
--- /dev/null
+++ b/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java
@@ -0,0 +1,27 @@
+package com.baeldung.nativekeyword;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+
+public class DateTimeUtilsManualTest {
+
+ private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(DateTimeUtilsManualTest.class);
+
+ @BeforeClass
+ public static void setUpClass() {
+ System.loadLibrary("msvcr100");
+ System.loadLibrary("libgcc_s_sjlj-1");
+ System.loadLibrary("libstdc++-6");
+ System.loadLibrary("nativedatetimeutils");
+ }
+
+ @Test
+ public void givenNativeLibsLoaded_thenNativeMethodIsAccessible() {
+ DateTimeUtils dateTimeUtils = new DateTimeUtils();
+ LOG.info("System time is : " + dateTimeUtils.getSystemTime());
+ assertNotNull(dateTimeUtils.getSystemTime());
+ }
+}
diff --git a/core-java-lang/src/test/java/com/baeldung/packages/PackagesUnitTest.java b/core-java-lang/src/test/java/com/baeldung/packages/PackagesUnitTest.java
new file mode 100644
index 0000000000..212fb7b3c7
--- /dev/null
+++ b/core-java-lang/src/test/java/com/baeldung/packages/PackagesUnitTest.java
@@ -0,0 +1,23 @@
+package com.baeldung.packages;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.LocalDate;
+
+import org.junit.Test;
+
+import com.baeldung.packages.domain.TodoItem;
+
+public class PackagesUnitTest {
+
+ @Test
+ public void whenTodoItemAdded_ThenSizeIncreases() {
+ TodoItem todoItem = new TodoItem();
+ todoItem.setId(1L);
+ todoItem.setDescription("Test the Todo List");
+ todoItem.setDueDate(LocalDate.now());
+ TodoList todoList = new TodoList();
+ todoList.addTodoItem(todoItem);
+ assertEquals(1, todoList.getTodoItems().size());
+ }
+}
diff --git a/core-java-networking/.gitignore b/core-java-networking/.gitignore
new file mode 100644
index 0000000000..374c8bf907
--- /dev/null
+++ b/core-java-networking/.gitignore
@@ -0,0 +1,25 @@
+*.class
+
+0.*
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+.resourceCache
+
+# Packaged files #
+*.jar
+*.war
+*.ear
+
+# Files generated by integration tests
+backup-pom.xml
+/bin/
+/temp
+
+#IntelliJ specific
+.idea/
+*.iml
\ No newline at end of file
diff --git a/core-java-networking/README.md b/core-java-networking/README.md
new file mode 100644
index 0000000000..b2367782b6
--- /dev/null
+++ b/core-java-networking/README.md
@@ -0,0 +1,16 @@
+=========
+
+## Core Java Networking
+
+### Relevant Articles
+
+- [Connecting Through Proxy Servers in Core Java](https://www.baeldung.com/java-connect-via-proxy-server)
+- [Broadcasting and Multicasting in Java](http://www.baeldung.com/java-broadcast-multicast)
+- [A Guide To UDP In Java](http://www.baeldung.com/udp-in-java)
+- [Sending Emails with Java](http://www.baeldung.com/java-email)
+- [A Guide To HTTP Cookies In Java](http://www.baeldung.com/cookies-java)
+- [A Guide to the Java URL](http://www.baeldung.com/java-url)
+- [Working with Network Interfaces in Java](http://www.baeldung.com/java-network-interfaces)
+- [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets)
+- [URL Encoding and Decoding in Java](http://www.baeldung.com/java-url-encoding-decoding)
+- [How to Perform a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request)
\ No newline at end of file
diff --git a/core-java-networking/pom.xml b/core-java-networking/pom.xml
new file mode 100644
index 0000000000..d9c7c691e9
--- /dev/null
+++ b/core-java-networking/pom.xml
@@ -0,0 +1,49 @@
+
+ 4.0.0
+ core-java-networking
+ 0.1.0-SNAPSHOT
+ jar
+ core-java-networking
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+
+ javax.mail
+ mail
+ ${javax.mail.version}
+
+
+ commons-io
+ commons-io
+ ${commons-io.version}
+
+
+ org.springframework
+ spring-web
+ ${springframework.spring-web.version}
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+
+
+ core-java-networking
+
+
+
+ 1.5.0-b01
+ 2.5
+ 3.5
+ 4.3.4.RELEASE
+
+
diff --git a/core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java b/core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java
new file mode 100644
index 0000000000..394255bd70
--- /dev/null
+++ b/core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java
@@ -0,0 +1,65 @@
+package com.baeldung.http;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.HttpURLConnection;
+import java.util.Iterator;
+import java.util.List;
+
+public class FullResponseBuilder {
+ public static String getFullResponse(HttpURLConnection con) throws IOException {
+ StringBuilder fullResponseBuilder = new StringBuilder();
+
+ fullResponseBuilder.append(con.getResponseCode())
+ .append(" ")
+ .append(con.getResponseMessage())
+ .append("\n");
+
+ con.getHeaderFields()
+ .entrySet()
+ .stream()
+ .filter(entry -> entry.getKey() != null)
+ .forEach(entry -> {
+
+ fullResponseBuilder.append(entry.getKey())
+ .append(": ");
+
+ List headerValues = entry.getValue();
+ Iterator it = headerValues.iterator();
+ if (it.hasNext()) {
+ fullResponseBuilder.append(it.next());
+
+ while (it.hasNext()) {
+ fullResponseBuilder.append(", ")
+ .append(it.next());
+ }
+ }
+
+ fullResponseBuilder.append("\n");
+ });
+
+ Reader streamReader = null;
+
+ if (con.getResponseCode() > 299) {
+ streamReader = new InputStreamReader(con.getErrorStream());
+ } else {
+ streamReader = new InputStreamReader(con.getInputStream());
+ }
+
+ BufferedReader in = new BufferedReader(streamReader);
+ String inputLine;
+ StringBuilder content = new StringBuilder();
+ while ((inputLine = in.readLine()) != null) {
+ content.append(inputLine);
+ }
+
+ in.close();
+
+ fullResponseBuilder.append("Response: ")
+ .append(content);
+
+ return fullResponseBuilder.toString();
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/http/ParameterStringBuilder.java b/core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/http/ParameterStringBuilder.java
rename to core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java
diff --git a/core-java/src/main/java/com/baeldung/mail/EmailService.java b/core-java-networking/src/main/java/com/baeldung/mail/EmailService.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/mail/EmailService.java
rename to core-java-networking/src/main/java/com/baeldung/mail/EmailService.java
diff --git a/core-java/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java b/core-java-networking/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java
rename to core-java-networking/src/main/java/com/baeldung/networking/cookies/PersistentCookieStore.java
diff --git a/core-java/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java b/core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java
rename to core-java-networking/src/main/java/com/baeldung/networking/cookies/ProxyAcceptCookiePolicy.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java b/core-java-networking/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java
rename to core-java-networking/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java b/core-java-networking/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java
rename to core-java-networking/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java b/core-java-networking/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java
rename to core-java-networking/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java b/core-java-networking/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java
rename to core-java-networking/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java b/core-java-networking/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java
rename to core-java-networking/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java b/core-java-networking/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java
rename to core-java-networking/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/udp/EchoClient.java b/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoClient.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/udp/EchoClient.java
rename to core-java-networking/src/main/java/com/baeldung/networking/udp/EchoClient.java
diff --git a/core-java/src/main/java/com/baeldung/networking/udp/EchoServer.java b/core-java-networking/src/main/java/com/baeldung/networking/udp/EchoServer.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/udp/EchoServer.java
rename to core-java-networking/src/main/java/com/baeldung/networking/udp/EchoServer.java
diff --git a/core-java/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java b/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java
rename to core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingClient.java
diff --git a/core-java/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java b/core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java
rename to core-java-networking/src/main/java/com/baeldung/networking/udp/broadcast/BroadcastingEchoServer.java
diff --git a/core-java/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java b/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java
rename to core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastEchoServer.java
diff --git a/core-java/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java b/core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java
rename to core-java-networking/src/main/java/com/baeldung/networking/udp/multicast/MulticastingClient.java
diff --git a/core-java/src/main/java/com/baeldung/javanetworking/uriurl/URIDemo.java b/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URIDemo.java
similarity index 98%
rename from core-java/src/main/java/com/baeldung/javanetworking/uriurl/URIDemo.java
rename to core-java-networking/src/main/java/com/baeldung/networking/uriurl/URIDemo.java
index 121e0f5d72..91f6e21293 100644
--- a/core-java/src/main/java/com/baeldung/javanetworking/uriurl/URIDemo.java
+++ b/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URIDemo.java
@@ -1,4 +1,4 @@
-package com.baeldung.javanetworking.uriurl;
+package com.baeldung.networking.uriurl;
import java.io.BufferedReader;
import java.io.IOException;
diff --git a/core-java/src/main/java/com/baeldung/javanetworking/uriurl/URLDemo.java b/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URLDemo.java
similarity index 98%
rename from core-java/src/main/java/com/baeldung/javanetworking/uriurl/URLDemo.java
rename to core-java-networking/src/main/java/com/baeldung/networking/uriurl/URLDemo.java
index 109a9951d2..d257e7a295 100644
--- a/core-java/src/main/java/com/baeldung/javanetworking/uriurl/URLDemo.java
+++ b/core-java-networking/src/main/java/com/baeldung/networking/uriurl/URLDemo.java
@@ -1,4 +1,4 @@
-package com.baeldung.javanetworking.uriurl;
+package com.baeldung.networking.uriurl;
import java.io.BufferedReader;
import java.io.IOException;
diff --git a/core-java/src/main/java/com/baeldung/socket/EchoClient.java b/core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/socket/EchoClient.java
rename to core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java
diff --git a/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java b/core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java
rename to core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java
diff --git a/core-java/src/main/java/com/baeldung/socket/EchoServer.java b/core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/socket/EchoServer.java
rename to core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java
diff --git a/core-java/src/main/java/com/baeldung/socket/GreetClient.java b/core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/socket/GreetClient.java
rename to core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java
diff --git a/core-java/src/main/java/com/baeldung/socket/GreetServer.java b/core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/socket/GreetServer.java
rename to core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java
diff --git a/spring-rest-embedded-tomcat/src/main/resources/logback.xml b/core-java-networking/src/main/resources/logback.xml
similarity index 57%
rename from spring-rest-embedded-tomcat/src/main/resources/logback.xml
rename to core-java-networking/src/main/resources/logback.xml
index 7d900d8ea8..56af2d397e 100644
--- a/spring-rest-embedded-tomcat/src/main/resources/logback.xml
+++ b/core-java-networking/src/main/resources/logback.xml
@@ -7,6 +7,12 @@
+
+
+
+
+
+
diff --git a/core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java b/core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java
rename to core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java
diff --git a/core-java/src/test/java/com/baeldung/http/HttpRequestLiveTest.java b/core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java
similarity index 64%
rename from core-java/src/test/java/com/baeldung/http/HttpRequestLiveTest.java
rename to core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java
index acd6536ac4..bd6c0a4410 100644
--- a/core-java/src/test/java/com/baeldung/http/HttpRequestLiveTest.java
+++ b/core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java
@@ -1,12 +1,13 @@
package com.baeldung.http;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.Reader;
import java.net.CookieManager;
import java.net.HttpCookie;
import java.net.HttpURLConnection;
@@ -48,7 +49,8 @@ public class HttpRequestLiveTest {
in.close();
assertEquals("status code incorrect", status, 200);
- assertTrue("content incorrect", content.toString().contains("Example Domain"));
+ assertTrue("content incorrect", content.toString()
+ .contains("Example Domain"));
}
@Test
@@ -89,18 +91,24 @@ public class HttpRequestLiveTest {
Optional usernameCookie = null;
if (cookiesHeader != null) {
List cookies = HttpCookie.parse(cookiesHeader);
- cookies.forEach(cookie -> cookieManager.getCookieStore().add(null, cookie));
- usernameCookie = cookies.stream().findAny().filter(cookie -> cookie.getName().equals("username"));
+ cookies.forEach(cookie -> cookieManager.getCookieStore()
+ .add(null, cookie));
+ usernameCookie = cookies.stream()
+ .findAny()
+ .filter(cookie -> cookie.getName()
+ .equals("username"));
}
if (usernameCookie == null) {
- cookieManager.getCookieStore().add(null, new HttpCookie("username", "john"));
+ cookieManager.getCookieStore()
+ .add(null, new HttpCookie("username", "john"));
}
con.disconnect();
con = (HttpURLConnection) url.openConnection();
- con.setRequestProperty("Cookie", StringUtils.join(cookieManager.getCookieStore().getCookies(), ";"));
+ con.setRequestProperty("Cookie", StringUtils.join(cookieManager.getCookieStore()
+ .getCookies(), ";"));
int status = con.getResponseCode();
@@ -125,4 +133,56 @@ public class HttpRequestLiveTest {
assertEquals("status code incorrect", con.getResponseCode(), 200);
}
+ @Test
+ public void whenFailedRequest_thenOk() throws IOException {
+ URL url = new URL("http://example.com");
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ con.setRequestMethod("POST");
+
+ con.setConnectTimeout(5000);
+ con.setReadTimeout(5000);
+
+ int status = con.getResponseCode();
+
+ Reader streamReader = null;
+
+ if (status > 299) {
+ streamReader = new InputStreamReader(con.getErrorStream());
+ } else {
+ streamReader = new InputStreamReader(con.getInputStream());
+ }
+
+ BufferedReader in = new BufferedReader(streamReader);
+ String inputLine;
+ StringBuilder content = new StringBuilder();
+ while ((inputLine = in.readLine()) != null) {
+ content.append(inputLine);
+ }
+ in.close();
+
+ con.disconnect();
+
+ assertEquals("status code incorrect", status, 411);
+ assertTrue("error content", content.toString()
+ .contains("411 - Length Required"));
+ }
+
+ @Test
+ public void whenGetRequestFullResponse_thenOk() throws IOException {
+ URL url = new URL("http://example.com");
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ con.setRequestMethod("GET");
+
+ con.setConnectTimeout(5000);
+ con.setReadTimeout(5000);
+
+ String fullResponse = FullResponseBuilder.getFullResponse(con);
+
+ con.disconnect();
+
+ assertEquals("status code incorrect", con.getResponseCode(), 200);
+ assertTrue("header incorrect", fullResponse.contains("Content-Type: text/html; charset=UTF-8"));
+ assertTrue("response incorrect", fullResponse.contains(""));
+ }
+
}
diff --git a/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceManualTest.java b/core-java-networking/src/test/java/com/baeldung/networking/interfaces/NetworkInterfaceManualTest.java
similarity index 98%
rename from core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceManualTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/interfaces/NetworkInterfaceManualTest.java
index 8635a24f18..47a598f599 100644
--- a/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceManualTest.java
+++ b/core-java-networking/src/test/java/com/baeldung/networking/interfaces/NetworkInterfaceManualTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.java.networking.interfaces;
+package com.baeldung.networking.interfaces;
import org.junit.Test;
diff --git a/core-java/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java b/core-java-networking/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/udp/UDPLiveTest.java
diff --git a/core-java/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java b/core-java-networking/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/udp/broadcast/BroadcastLiveTest.java
diff --git a/core-java/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java b/core-java-networking/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/udp/multicast/MulticastLiveTest.java
diff --git a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/test/URIDemoLiveTest.java b/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIDemoLiveTest.java
similarity index 95%
rename from core-java/src/test/java/com/baeldung/javanetworking/uriurl/test/URIDemoLiveTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIDemoLiveTest.java
index 0c312ff613..3b73cc0943 100644
--- a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/test/URIDemoLiveTest.java
+++ b/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIDemoLiveTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.javanetworking.uriurl.test;
+package com.baeldung.networking.uriurl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -20,7 +20,7 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.baeldung.javanetworking.uriurl.URLDemo;
+import com.baeldung.networking.uriurl.URLDemo;
@FixMethodOrder
public class URIDemoLiveTest {
diff --git a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/URIvsURLUnitTest.java b/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIvsURLUnitTest.java
similarity index 98%
rename from core-java/src/test/java/com/baeldung/javanetworking/uriurl/URIvsURLUnitTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIvsURLUnitTest.java
index 8837dc5556..ec1cb4c0c9 100644
--- a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/URIvsURLUnitTest.java
+++ b/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URIvsURLUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.javanetworking.uriurl;
+package com.baeldung.networking.uriurl;
import java.io.IOException;
import java.net.MalformedURLException;
diff --git a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/test/URLDemoLiveTest.java b/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URLDemoLiveTest.java
similarity index 97%
rename from core-java/src/test/java/com/baeldung/javanetworking/uriurl/test/URLDemoLiveTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/uriurl/URLDemoLiveTest.java
index 15f53ed878..a9104311e6 100644
--- a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/test/URLDemoLiveTest.java
+++ b/core-java-networking/src/test/java/com/baeldung/networking/uriurl/URLDemoLiveTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.javanetworking.uriurl.test;
+package com.baeldung.networking.uriurl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -18,7 +18,7 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.baeldung.javanetworking.uriurl.URLDemo;
+import com.baeldung.networking.uriurl.URLDemo;
@FixMethodOrder
public class URLDemoLiveTest {
diff --git a/core-java/src/test/java/com/baeldung/java/networking/url/UrlUnitTest.java b/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java
similarity index 98%
rename from core-java/src/test/java/com/baeldung/java/networking/url/UrlUnitTest.java
rename to core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java
index 505d9595ab..112f2cf53f 100644
--- a/core-java/src/test/java/com/baeldung/java/networking/url/UrlUnitTest.java
+++ b/core-java-networking/src/test/java/com/baeldung/networking/url/UrlUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.java.networking.url;
+package com.baeldung.networking.url;
import static org.junit.Assert.assertEquals;
diff --git a/core-java/src/test/java/com/baeldung/socket/EchoIntegrationTest.java b/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/socket/EchoIntegrationTest.java
rename to core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java
diff --git a/core-java/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java b/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java
rename to core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java
diff --git a/core-java/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java b/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java
rename to core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java
diff --git a/core-java-networking/src/test/resources/.gitignore b/core-java-networking/src/test/resources/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/core-java-networking/src/test/resources/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/core-java-perf/README.md b/core-java-perf/README.md
new file mode 100644
index 0000000000..252ee4cc45
--- /dev/null
+++ b/core-java-perf/README.md
@@ -0,0 +1,8 @@
+## Core Java Performance
+
+### Relevant Articles:
+- [Verbose Garbage Collection in Java](https://www.baeldung.com/java-verbose-gc)
+- [Different Ways to Capture Java Heap Dumps](https://www.baeldung.com/java-heap-dump-capture)
+- [Understanding Memory Leaks in Java](https://www.baeldung.com/java-memory-leaks)
+- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded)
+- [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions)
\ No newline at end of file
diff --git a/core-java-perf/pom.xml b/core-java-perf/pom.xml
new file mode 100644
index 0000000000..062f76db77
--- /dev/null
+++ b/core-java-perf/pom.xml
@@ -0,0 +1,33 @@
+
+ 4.0.0
+ com.baeldung
+ core-java-perf
+ 0.1.0-SNAPSHOT
+ jar
+ core-java-perf
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+
+
+
+
+
+ 3.8.1
+
+
+
+
diff --git a/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java b/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java
new file mode 100644
index 0000000000..f57580bbb5
--- /dev/null
+++ b/core-java-perf/src/main/java/com/baeldung/gc/VerboseGarbageCollectorRunner.java
@@ -0,0 +1,63 @@
+package com.baeldung.gc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A simple Java program to demonstrate how to enable verbose Garbage Collection (GC) logging.
+ *
+ * This simple program loads 3 million {@link java.lang.String} instances into a {@link java.util.HashMap}
+ * object before making an explicit call to the garbage collector using System.gc().
+ *
+ * Finally, it removes 2 million of the {@link java.lang.String} instances from the {@link java.util.HashMap}.
+ * We also explicitly use System.out.println to make interpreting the output easier.
+ *
+ * Run this program with the following arguments to see verbose GC logging in its complete form:
+ *