This commit is contained in:
2024-02-09 19:33:41 +01:00
parent 2ac91ff699
commit d84ea072ef
22 changed files with 180 additions and 8 deletions

View File

@@ -3,7 +3,7 @@
<properties maven-id="org.openjfx:javafx-base:20-ea+2" /> <properties maven-id="org.openjfx:javafx-base:20-ea+2" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/20-ea+2/javafx-base-20-ea+2-win.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@@ -3,11 +3,11 @@
<properties maven-id="org.openjfx:javafx-controls:22-ea+16" /> <properties maven-id="org.openjfx:javafx-controls:22-ea+16" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/22-ea+16/javafx-controls-22-ea+16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-win.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@@ -3,9 +3,9 @@
<properties maven-id="org.openjfx:javafx-graphics:22-ea+16" /> <properties maven-id="org.openjfx:javafx-graphics:22-ea+16" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/22-ea+16/javafx-graphics-22-ea+16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-linux.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/22-ea+16/javafx-base-22-ea+16-win.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

4
.idea/misc.xml generated
View File

@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" /> <component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="ProjectRootManager" version="2" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project> </project>

View File

@@ -10,6 +10,5 @@
<orderEntry type="library" name="openjfx.javafx.base" level="project" /> <orderEntry type="library" name="openjfx.javafx.base" level="project" />
<orderEntry type="library" name="openjfx.javafx.graphics" level="project" /> <orderEntry type="library" name="openjfx.javafx.graphics" level="project" />
<orderEntry type="library" name="openjfx.javafx.controls" level="project" /> <orderEntry type="library" name="openjfx.javafx.controls" level="project" />
<orderEntry type="library" name="scala-sdk-2.13.12" level="application" />
</component> </component>
</module> </module>

View File

@@ -0,0 +1,45 @@
package Klausur_ueb;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
public class LambdaTraining {
public static void main(String[] args) {
refMethod();
}
static void hello(){
String[] ar = { "Hello ", "Lambda ", "World!" };
Arrays.asList(ar).forEach(s -> System.out.print(s));
Arrays.asList(ar).forEach(System.out::print);
}
static void square(){
Square i = (int q,int r) -> q*r; System.out.println(i.calculate(7,1));
List <Double > ld = new ArrayList < >();
ld.add(1.0);
ld.add(2.2);
ld.add(0.3);
ld.forEach(System.out::println);
}
static void anonClass(){
String[] ar = { "Hello ", "Lambda ", "World!" };
Arrays.asList(ar).forEach(
new Consumer<String>() {
public void accept(String t) {
System.out.print(t);
}
} );
}
static void refMethod(){
List<Integer> data = Arrays.asList(7, 2, 5, 4);
Optional <Integer > minimum = data.stream().reduce(Math::min);
System.out.println(minimum);
}
}
@FunctionalInterface
interface Square {
int calculate(int q, int r);
}

View File

@@ -0,0 +1,66 @@
package Klausur_ueb;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
//P5
public class StreamsTraining {
public static void main(String[] args) {
//startFib();
//directFib();
//lorem();
//System.out.println(fak(25));
//System.out.println(fak(15));
lorem2();
}
static void startFib(){
for(int i:fibonacci(10)){
System.out.println(i);
}
}
public static List<Integer> fibonacci (int amount){
return Stream.iterate(new Integer[] {0,1},s -> new Integer[] {s[1],s[0]+s[1]})// start with 0,1. Set s[0] to s[1] and s[1] to s[0] + s[1]
.limit(amount)
.map(s->s[0])//only take s[0]
.collect(Collectors.toList());
}
static void directFib(){
Stream.iterate(new Integer[] {0,1},s -> new Integer[] {s[1],s[0]+s[1]})// start with 0,1. Set s[0] to s[1] and s[1] to s[0] + s[1]
.limit(10)
.map(s->s[0])//only take s[0]
.forEach(System.out::println);
}
static void lorem(){
String lorem = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
Stream.of(lorem)
.flatMap(line -> Arrays.stream( line.split(" ")))
.filter(w -> w.length()>6)
.forEach(System.out::println);
}
static void lorem2(){
String lorem = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
Arrays.stream(lorem.split("\\ |\\,|\\."))
.filter(w -> w.length() > 6)
.forEach(System.out::println);
}
static long fak(long input){
return LongStream.range(1,input+1)
.reduce(1, (x,y) -> x*y);
}
}

View File

@@ -0,0 +1,60 @@
package Klausur_ueb;
import java.util.concurrent.atomic.AtomicInteger;
public class ThreadTraining {
public static void main(String[] args) {
CoolNumber coolNumber = new CoolNumber();
for (int i = 0; i <= 10; i++) {
//Thread t = new MyThread();
Thread t = new MyThread2(coolNumber);
t.start();
}
System.out.println("Main fertig");
}
}
class MyThread extends Thread {
@Override
public void run() {
for (int i = 0; i <= 100; i++)
System.out.println(i);
}
}
class MyThread2 extends Thread {
CoolNumber cn;
public MyThread2(CoolNumber num) {
cn = num;
}
@Override
public void run() {
while (cn.tryToGet() != -1) {
try {
wait(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (Exception e) {
}
}
}
}
class CoolNumber {
int current = 0;
public synchronized int tryToGet() {
int tmp = current++;
if (tmp > 10)
return -1;
System.out.println(tmp);
return tmp;
}
}