-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d33ad01
commit 90bfec6
Showing
60 changed files
with
1,263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>new-features-in-java-interface</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
2 changes: 2 additions & 0 deletions
2
new-features-in-java-interface/.settings/org.eclipse.core.resources.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
encoding/<project>=UTF-8 |
14 changes: 14 additions & 0 deletions
14
new-features-in-java-interface/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=enabled | ||
org.eclipse.jdt.core.compiler.source=17 |
91 changes: 91 additions & 0 deletions
91
new-features-in-java-interface/src/com/example/StudyInterfaceJava8.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.example; | ||
|
||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
public class StudyInterfaceJava8 { | ||
|
||
public static void main(String[] args) { | ||
var numbers = List.of(4,8,15,16,23,42); | ||
numbers.stream() | ||
.filter( J::isEven ) | ||
.mapToInt( number -> number * number * number) | ||
.sum(); | ||
|
||
} | ||
|
||
} | ||
|
||
interface I { // before java 8 | ||
public abstract void fun(); | ||
public abstract void gun(); | ||
public abstract void sun(); | ||
} | ||
|
||
interface J { // after java 8+ | ||
public abstract void fun(); | ||
public abstract void gun(); | ||
public abstract void sun(); | ||
// 1. default method | ||
default public void run() { | ||
|
||
}; | ||
// 2. static method | ||
// Functional Programming Utility Method | ||
public static boolean isEven(int number) { | ||
return number%2 == 0; | ||
} | ||
} | ||
|
||
interface K { | ||
default void fun() { | ||
haveFun(); | ||
} | ||
default void sun() { | ||
haveFun(); | ||
} | ||
private void haveFun() {} // since java 9 | ||
public static void haveRun() { | ||
haveGun(); | ||
} | ||
public static void haveRun(int x) { | ||
haveGun(); | ||
} | ||
private static void haveGun() {} // since java 9 | ||
} | ||
|
||
class J1 implements J { | ||
|
||
@Override | ||
public void fun() { } | ||
|
||
@Override | ||
public void gun() { } | ||
|
||
@Override | ||
public void sun() { } | ||
|
||
} | ||
|
||
interface LotteryService { | ||
List<Integer> draw(int max,int size); | ||
|
||
default List<List<Integer>> draw(int max,int size,int column){ | ||
return IntStream.range(0, column) | ||
.mapToObj(i -> draw(max,size)) | ||
.toList(); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>study-arrays</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=enabled | ||
org.eclipse.jdt.core.compiler.source=17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.example; | ||
|
||
import java.util.Arrays; | ||
|
||
@SuppressWarnings("unused") | ||
public class StudyArray { | ||
|
||
public static void main(String[] args) { | ||
int x = 42; // scalar | ||
int[] numbers = { 4, 8, 15, 16, 23, 42 }; // Heap | ||
System.out.println(numbers.length); | ||
int[] dizi; | ||
dizi = new int[6]; // Heap -> Zero | ||
dizi[0] = 4; | ||
dizi[1] = 8; | ||
dizi[2] = 15; | ||
dizi[3] = 16; | ||
dizi[4] = 23; | ||
dizi[5] = 42; | ||
int[] array; | ||
array = new int[] { 4, 8, 15, 16, 23, 42 }; // Heap -> Zero | ||
// System.out.println(array[6]); ArrayIndexOutOfBoudsException | ||
// How to print array content | ||
System.out.println(numbers); | ||
System.out.println(Arrays.toString(numbers)); | ||
// Loop #1 | ||
for (int i = 0; i < numbers.length; ++i) | ||
System.out.println(numbers[i]); | ||
// Loop #1 - var | ||
for (var i = 0; i < numbers.length; ++i) | ||
System.out.println(numbers[i]); | ||
// Loop #2 : Java SE 5 - for-each | ||
for (var number : numbers) // safe, sequential, read-only | ||
System.out.println(++number); | ||
var sum = 0; | ||
for (var number : numbers) { | ||
if (number%2 == 1) { // if it is odd | ||
var squared = number * number; | ||
sum += squared; | ||
} | ||
} | ||
|
||
// Loop #3 : Java SE 8 -> Functional Programming | ||
sum = Arrays.stream(numbers) // Stream API + Filter/Map/Reduce -> ForkJoin Framework -> JobStealing Algorithm | ||
.parallel() | ||
.filter(u -> u%2 == 1) | ||
.map(y -> y*y) | ||
.sequential() | ||
.sum(); // Functional Programming: lazy-loading, functions? | ||
// C++20: Ranges -> C++23 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>study-date-time-api</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
4 changes: 4 additions & 0 deletions
4
study-date-time-api/.settings/org.eclipse.core.resources.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/com/example/CreatingDateAndTime.java=UTF-8 | ||
encoding//src/com/example/StudyInternationalization.java=UTF-8 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=enabled | ||
org.eclipse.jdt.core.compiler.source=17 |
30 changes: 30 additions & 0 deletions
30
study-date-time-api/src/com/example/CreatingDateAndTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.FormatStyle; | ||
import java.util.Locale; | ||
|
||
public class CreatingDateAndTime { | ||
|
||
@SuppressWarnings("unused") | ||
public static void main(String[] args) { | ||
var tr = new Locale("tr","TR"); | ||
LocalDate localDate; | ||
LocalTime localTime; | ||
LocalDateTime localDateTime; | ||
ZonedDateTime now = ZonedDateTime.now(); | ||
System.out.println(LocalDate.now()); | ||
System.out.println(LocalTime.now()); | ||
System.out.println(LocalDateTime.now()); | ||
System.out.println(ZonedDateTime.now()); | ||
DateTimeFormatter dtf = | ||
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL) | ||
.withLocale(Locale.CHINA); | ||
System.out.println(dtf.format(now)); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
study-date-time-api/src/com/example/CreatingSpecificDateAndTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
import java.time.Month; | ||
|
||
public class CreatingSpecificDateAndTime { | ||
|
||
@SuppressWarnings("unused") | ||
public static void main(String[] args) { | ||
var birthDate1 = LocalDate.of(1973, Month.JULY, 11); | ||
var birthDate2 = LocalDate.of(1973, 7, 11); | ||
var time1 = LocalTime.of(9, 5); | ||
var time2 = LocalTime.of(9, 5, 30); | ||
var time3 = LocalTime.of(9, 5, 30, 200); | ||
LocalDate.of(2020, Month.FEBRUARY, 30); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
study-date-time-api/src/com/example/DateTimeOperations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
|
||
public class DateTimeOperations { | ||
|
||
public static void main(String[] args) { | ||
LocalDate date = LocalDate.of(2100, 2, 27); | ||
System.out.println(date); | ||
date = date.plusDays(2); | ||
System.out.println(date); | ||
LocalTime time = LocalTime.of(9, 5); | ||
System.out.println(time); | ||
time = time.minusMinutes(10); | ||
System.out.println(time); | ||
// fluent api -> method chaining | ||
LocalDateTime ldt = LocalDateTime.of(date,time); | ||
System.out.println(ldt); | ||
ldt = ldt.minusDays(1).minusHours(10).minusSeconds(30); | ||
System.out.println(ldt); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.example; | ||
|
||
import java.time.Duration; | ||
import java.time.LocalTime; | ||
|
||
public class StudyDuration { | ||
|
||
public static void main(String[] args) { | ||
var daily = Duration.ofDays(1); | ||
var hourly = Duration.ofHours(1); | ||
LocalTime time = LocalTime.of(9, 5); | ||
time = time.plus(daily).plus(hourly); | ||
} | ||
|
||
} |
Oops, something went wrong.