Merge branch 'eugenp:master' into master

This commit is contained in:
jsgrah-spring 2022-11-03 02:23:42 +01:00 committed by GitHub
commit 7c383c0d39
18 changed files with 58 additions and 13 deletions

View File

@ -4,4 +4,5 @@
- [Sorting Strings by Contained Numbers in Java](https://www.baeldung.com/java-sort-strings-contained-numbers)
- [Guide to In-Place Sorting Algorithm Works with a Java Implementation](https://www.baeldung.com/java-in-place-sorting)
- [Partitioning and Sorting Arrays with Many Repeated Entries with Java Examples](https://www.baeldung.com/java-sorting-arrays-with-repeated-entries)
- [Gravity/Bead Sort in Java](https://www.baeldung.com/java-gravity-bead-sort)
- More articles: [[<-- prev]](/algorithms-sorting)

View File

@ -1,3 +1,4 @@
## Relevant articles
- [Using Streams to Collect Into a TreeSet](https://www.baeldung.com/java-stream-collect-into-treeset)
- [A Guide to LinkedHashSet in Java](https://www.baeldung.com/java-linkedhashset)

View File

@ -0,0 +1,35 @@
package com.baeldung.math.standarddeviation;
import java.util.Arrays;
public class StandardDeviation {
public static double calculateStandardDeviation(double[] array) {
// get the sum of array
double sum = 0.0;
for (double i : array) {
sum += i;
}
// get the mean of array
int length = array.length;
double mean = sum / length;
// calculate the standard deviation
double standardDeviation = 0.0;
for (double num : array) {
standardDeviation += Math.pow(num - mean, 2);
}
return Math.sqrt(standardDeviation / length);
}
public static void main(String[] args) {
double[] array = {25, 5, 45, 68, 61, 46, 24, 95};
System.out.println("List of elements: " + Arrays.toString(array));
double standardDeviation = calculateStandardDeviation(array);
System.out.format("Standard Deviation = %.6f", standardDeviation);
}
}

View File

@ -0,0 +1,2 @@
## Relevant Articles:
- [Difference Between URI.create() and new URI()](https://www.baeldung.com/java-uri-create-and-new-uri)

View File

@ -174,7 +174,7 @@
<gson.version>2.8.2</gson.version>
<cache.version>1.1.1</cache.version>
<flink.version>1.5.0</flink.version>
<hazelcast.version>3.8.4</hazelcast.version>
<hazelcast.version>5.2.0</hazelcast.version>
<org.apache.crunch.crunch-core.version>0.15.0</org.apache.crunch.crunch-core.version>
<org.apache.hadoop.hadoop-client>2.2.0</org.apache.hadoop.hadoop-client>
<jmapper.version>1.6.0.1</jmapper.version>

View File

@ -16,21 +16,22 @@ import org.junit.Test;
public class CacheLoaderIntegrationTest {
private static final String CACHE_NAME = "SimpleCache";
private static final String HAZELCAST_MEMBER_CACHING_PROVIDER = "com.hazelcast.cache.HazelcastMemberCachingProvider";
private Cache<Integer, String> cache;
@Before
public void setup() {
// Adding fully qualified class name because of multiple Cache Provider (Ignite and Hazelcast)
CachingProvider cachingProvider = Caching.getCachingProvider("com.hazelcast.cache.HazelcastCachingProvider");
CachingProvider cachingProvider = Caching.getCachingProvider(HAZELCAST_MEMBER_CACHING_PROVIDER);
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Integer, String> config = new MutableConfiguration<Integer, String>().setReadThrough(true).setCacheLoaderFactory(new FactoryBuilder.SingletonFactory<>(new SimpleCacheLoader()));
this.cache = cacheManager.createCache("SimpleCache", config);
this.cache = cacheManager.createCache( CACHE_NAME, config );
}
@After
public void tearDown() {
Caching.getCachingProvider("com.hazelcast.cache.HazelcastCachingProvider").getCacheManager().destroyCache(CACHE_NAME);
Caching.getCachingProvider(HAZELCAST_MEMBER_CACHING_PROVIDER).getCacheManager().destroyCache(CACHE_NAME);
}
@Test

View File

@ -1,4 +1,4 @@
package com.baeldung.factoryGeneric;
package com.baeldung.factorygeneric;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package com.baeldung.factoryGeneric;
package com.baeldung.factorygeneric;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package com.baeldung.factoryGeneric;
package com.baeldung.factorygeneric;
public interface Notifier<T> {

View File

@ -1,4 +1,4 @@
package com.baeldung.factoryGeneric;
package com.baeldung.factorygeneric;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package com.baeldung.factoryGeneric;
package com.baeldung.factorygeneric;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package com.baeldung.factoryGeneric;
package com.baeldung.factorygeneric;
public class StringNotifier implements Notifier<String> {

View File

@ -1,4 +1,4 @@
package com.baeldung.factoryGeneric;
package com.baeldung.factorygeneric;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

View File

@ -5,3 +5,4 @@ This module contains articles about Spring 5 WebFlux
## Relevant articles:
- [Spring Webflux and @Cacheable Annotation](https://www.baeldung.com/spring-webflux-cacheable)
- [Comparison Between Monos doOnNext() and doOnSuccess()](https://www.baeldung.com/mono-doonnext-doonsuccess)
- [How to Access the First Element of a Flux](https://www.baeldung.com/java-flux-first-element)

View File

@ -6,4 +6,5 @@ This module contains articles about Spring with Groovy
### Relevant Articles:
- [Building a Simple Web Application with Spring Boot and Groovy](https://www.baeldung.com/spring-boot-groovy-web-app)
- [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans)
- [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans)
- [Using Groovy in Spring](https://www.baeldung.com/groovy/spring-using-groovy)

View File

@ -8,4 +8,5 @@
- [How to Define a Map in YAML for a POJO?](https://www.baeldung.com/yaml-map-pojo)
- [Using application.yml vs application.properties in Spring Boot](https://www.baeldung.com/spring-boot-yaml-vs-properties)
- [Load Spring Boot Properties From a JSON File](https://www.baeldung.com/spring-boot-json-properties)
- [IntelliJ Cannot Resolve Spring Boot Configuration Properties Error](https://www.baeldung.com/intellij-resolve-spring-boot-configuration-properties)
- [IntelliJ Cannot Resolve Spring Boot Configuration Properties Error](https://www.baeldung.com/intellij-resolve-spring-boot-configuration-properties)
- [Log Properties in a Spring Boot Application](https://www.baeldung.com/spring-boot-log-properties)

View File

@ -6,4 +6,5 @@ This module contains articles about reactive Spring 5 WebClient
The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles
- [Limiting the Requests per Second With WebClient](https://www.baeldung.com/spring-webclient-limit-requests-per-second)
- More articles: [[<-- prev]](../spring-5-reactive-client)

View File

@ -8,3 +8,4 @@
- [Determine the Execution Time of JUnit Tests](https://www.baeldung.com/junit-test-execution-time)
- [@BeforeAll and @AfterAll in Non-Static Methods](https://www.baeldung.com/java-beforeall-afterall-non-static)
- [The java.lang.NoClassDefFoundError in JUnit](https://www.baeldung.com/junit-noclassdeffounderror)
- [assertAll() vs Multiple Assertions in JUnit5](https://github.com/eugenp/tutorials/tree/master/testing-modules/junit-5)