This commit is contained in:
@@ -4,7 +4,6 @@ This module contains modules about core Java
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
- [Multi-Module Maven Application with Java Modules](https://www.baeldung.com/maven-multi-module-project-java-jpms)
|
||||
- [Guide to Java FileChannel](https://www.baeldung.com/java-filechannel)
|
||||
- [Understanding the NumberFormatException in Java](https://www.baeldung.com/java-number-format-exception)
|
||||
- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch)
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ This module contains articles about Java 11 core features
|
||||
|
||||
### Relevant articles
|
||||
|
||||
- [Java 11 Single File Source Code](https://www.baeldung.com/java-single-file-source-code)
|
||||
- [Java 11 Single File Source Code](https://www.baeldung.com/java-single-file-source-codehttps://www.baeldung.com/java-single-file-source-code)
|
||||
- [Java 11 Local Variable Syntax for Lambda Parameters](https://www.baeldung.com/java-var-lambda-params)
|
||||
- [Java 11 String API Additions](https://www.baeldung.com/java-11-string-api)
|
||||
- [Java 11 Nest Based Access Control](https://www.baeldung.com/java-nest-based-access-control)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-8-2</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-8-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Runs all available formatter
|
||||
* @throws ParseException
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
List<Locale> locales = Arrays.asList(new Locale[] { Locale.UK, Locale.ITALY, Locale.FRANCE, Locale.forLanguageTag("pl-PL") });
|
||||
List<Locale> locales = Arrays.asList(new Locale[]{Locale.UK, Locale.ITALY, Locale.FRANCE, Locale.forLanguageTag("pl-PL")});
|
||||
Localization.run(locales);
|
||||
JavaSEFormat.run(locales);
|
||||
ICUFormat.run(locales);
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.ossez.number.foramt;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
|
||||
public class NumberFormatExceptionTest {
|
||||
|
||||
|
||||
String stringPassword = "password";
|
||||
char[] charPassword = new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
|
||||
|
||||
@Test
|
||||
public void ConstructorNumberFormatException() {
|
||||
Exception exception = assertThrows(NumberFormatException.class, () -> {
|
||||
new Integer("one");
|
||||
});
|
||||
|
||||
System.out.println(exception);
|
||||
|
||||
Integer aIntegerObj = new Integer("one");
|
||||
Double doubleDecimalObj = new Double("two.2");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+14
-17
@@ -10,9 +10,9 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class MultiLineString {
|
||||
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
|
||||
|
||||
public String stringConcatenation() {
|
||||
return "Get busy living"
|
||||
.concat(newLine)
|
||||
@@ -22,7 +22,7 @@ public class MultiLineString {
|
||||
.concat(newLine)
|
||||
.concat("--Stephen King");
|
||||
}
|
||||
|
||||
|
||||
public String stringJoin() {
|
||||
return String.join(newLine,
|
||||
"Get busy living",
|
||||
@@ -30,7 +30,7 @@ public class MultiLineString {
|
||||
"get busy dying.",
|
||||
"--Stephen King");
|
||||
}
|
||||
|
||||
|
||||
public String stringBuilder() {
|
||||
return new StringBuilder()
|
||||
.append("Get busy living")
|
||||
@@ -42,7 +42,7 @@ public class MultiLineString {
|
||||
.append("--Stephen King")
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
public String stringWriter() {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
@@ -52,26 +52,23 @@ public class MultiLineString {
|
||||
printWriter.println("--Stephen King");
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
|
||||
public String guavaJoiner() {
|
||||
return Joiner.on(newLine).join(ImmutableList.of("Get busy living",
|
||||
"or",
|
||||
"get busy dying.",
|
||||
"--Stephen King"));
|
||||
}
|
||||
|
||||
|
||||
public String loadFromFile() throws IOException {
|
||||
return new String(Files.readAllBytes(Paths.get("src/main/resources/stephenking.txt")));
|
||||
}
|
||||
|
||||
|
||||
// public String textBlocks() {
|
||||
//
|
||||
// // THIS ONLY FOR JDK 15
|
||||
// return """
|
||||
// Get busy living
|
||||
// or
|
||||
// get busy dying.
|
||||
// --Stephen King""";
|
||||
// }
|
||||
public String textBlocks() {
|
||||
return """
|
||||
Get busy living
|
||||
or
|
||||
get busy dying.
|
||||
--Stephen King""";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class MultiLineStringUnitTest {
|
||||
assertEquals(ms.stringJoin(), ms.stringBuilder());
|
||||
assertEquals(ms.stringBuilder(), ms.guavaJoiner());
|
||||
assertEquals(ms.guavaJoiner(), ms.loadFromFile());
|
||||
// assertEquals(ms.loadFromFile(), ms.textBlocks());
|
||||
assertEquals(ms.loadFromFile(), ms.textBlocks());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
<modules>
|
||||
<module>core-java-8</module>
|
||||
<module>core-java-8-2</module>
|
||||
<module>core-java-11</module>
|
||||
<module>core-java-11-2</module>
|
||||
<module>core-java-annotations</module>
|
||||
@@ -27,7 +28,9 @@
|
||||
<module>core-java-collections-list-3</module>
|
||||
<module>core-java-datetime-conversion</module>
|
||||
<module>core-java-io</module>
|
||||
<module>core-java-numbers</module>
|
||||
<module>core-java-streams</module>
|
||||
<module>core-java-strings</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
Reference in New Issue
Block a user