SlideShare a Scribd company logo
1
Java 14 Pattern Matching
Oleksandr Navka
Lead Software Engineer, Consultant, GlobalLogic
2
1. Updated instanceof
2. Updated switch-case
3. Java Records
Agenda
3
Тагир Валеев
JetBrains
Pattern matching
и его воображаемые друзья
4
5
When someone match something :)
What is pattern matching?
6
Any pattern
• _
Constant pattern
• 1
• true
• null
Type pattern
• String s
Var pattern
• var i = 1
Deconstruction pattern
• Optional(String s)
• Node(Node left, Node right)
What are the patterns?
7
Instanceof
8
public class Animal {
}
class Dog extends Animal {
public void bark() {
}
}
class Cat extends Animal {
public void meow() {
}
}
9
public static void say(Animal animal) {
if (animal instanceof Dog) {
Dog dog = (Dog) animal;
dog.bark();
} else if (animal instanceof Cat) {
Cat cat = (Cat) animal;
cat.meow();
}
}
10
public static void say(Animal animal) {
if (animal instanceof Dog) {
Dog dog = (Dog) animal;
dog.bark();
} else if (animal instanceof Cat) {
Cat cat = (Cat) animal;
cat.meow();
}
}
11
public static void say(Animal animal) {
if (animal instanceof Dog dog) {
dog.bark();
} else if (animal instanceof Cat cat) {
cat.meow();
}
}
12
public static void say(Animal animal) {
if (animal instanceof Dog dog) {
dog.bark();
} else if (animal instanceof Cat cat) {
cat.meow();
}
}
13
Before:
expression istanceof Type
Now:
expression instanceof Pattern
14
Scoping
15
if (obj instanceof String s) {
// can use s here
} else {
// can't use s here
}
16
if (obj instanceof String s) {
// can use s here
} else {
// can't use s here
}
binding variable
17
if (!(obj instanceof String s)) {
} else {
s.contains("a")
}
18
if(obj instanceof String s && s.length() > 5) {
System.out.println(s.toUpperCase());
}
19
if(obj instanceof String s || s.length() > 5) {
System.out.println(s.toUpperCase());
}
20
if(!(obj instanceof String s) || s.length() > 5) {
System.out.println("Do something");
} else {
System.out.println(s.toUpperCase());
}
21
if(!(obj instanceof String s) || s.length() > 5) {
System.out.println("Do something");
} else {
System.out.println(s.toUpperCase());
}
22
if(!(obj instanceof String s) || s.length() > 5) {
throw new IllegalArgumentException();
}
System.out.println(s.toUpperCase());
23
if(!(obj instanceof String s) || s.length() > 5) {
throw new IllegalArgumentException();
}
System.out.println(s.toUpperCase());
24
if (!(obj instanceof String s)) {
s.contains(..)
} else {
s.contains(..)
}
25
private String s = "abc";
if (!(obj instanceof String s)) {
s.contains(..)
} else {
s.contains(..)
}
26
1. if (obj instanceof String s) {s.trim()}
2. if (!(obj instanceof String s)) {} else {s.contains("a")}
3. if(obj instanceof String s && s.length() > 5) {}
4. if(obj instanceof String s || s.length() > 5) {}
Binding variable scope
27
1. if (obj instanceof String s) {s.trim()}
2. if (!(obj instanceof String s)) {} else {s.contains("a")}
3. if(obj instanceof String s && s.length() > 5) {}
4. if(obj instanceof String s || s.length() > 5) {}
Binding variable scope
28
1. if (obj instanceof String s) {s.trim()}
2. if (!(obj instanceof String s)) {} else {s.contains("a")}
3. if(obj instanceof String s && s.length() > 5) {}
4. if(obj instanceof String s || s.length() > 5) {}
5. if(!(obj instanceof String s) || s.length() > 5) {}
6. if(!(obj instanceof String s) || s.length() > 5) {} else {s.toUpperCase());}
7. if(!(obj instanceof String s) || s.length() > 5) {
throw new IllegalArgumentException();
}
System.out.println(s.toUpperCase());
Binding variable scope
29
1. instanceof has got type pattern matching
2. instanceof the first java feature that got pattern matching
3. Be aware about scoping
Instanceof Summary
30
Switch - case
31
public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL}
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
List<String> languages = new ArrayList<>();
switch (programmingParadigm) {
case OBJECT_ORIENTED:
languages.add("Java");
languages.add("C++");
break;
case FUNCTIONAL:
languages.add("Haskel");
break;
case PROCEDURAL:
languages.add("Pascal");
break;
}
return languages;
}
Old version of switch
32
public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL}
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
List<String> languages = new ArrayList<>();
switch (programmingParadigm) {
case OBJECT_ORIENTED:
languages.add("Java");
languages.add("C++");
break;
case FUNCTIONAL:
languages.add("Haskel");
break;
case PROCEDURAL:
languages.add("Pascal");
break;
}
return languages;
}
Old version of switch
33
public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL}
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
List<String> languages = new ArrayList<>();
switch (programmingParadigm) {
case OBJECT_ORIENTED:
languages.add("Java");
languages.add("C++");
break;
case FUNCTIONAL:
languages.add("Haskel");
break;
case PROCEDURAL:
languages.add("Pascal");
break;
}
return languages;
}
Old version of switch
Input type limitations:
byte, short, char, and int
Enum Types, String
34
public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL}
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
List<String> languages = new ArrayList<>();
switch (programmingParadigm) {
case OBJECT_ORIENTED:
languages.add("Java");
languages.add("C++");
break;
case FUNCTIONAL:
languages.add("Haskel");
break;
case PROCEDURAL:
languages.add("Pascal");
break;
}
return languages;
}
Old version of switch
Can’t
get
result
35
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
switch (programmingParadigm) {
case OBJECT_ORIENTED:
return List.of("Java", "C++");
case FUNCTIONAL:
return List.of("Haskel");
case PROCEDURAL:
return List.of("Pascal");
default:
return List.of();
}
}
36
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
switch (programmingParadigm) {
case OBJECT_ORIENTED:
return List.of("Java", "C++");
case FUNCTIONAL:
return List.of("Haskel");
case PROCEDURAL:
return List.of("Pascal");
default:
return List.of();
}
}
37
Disadvantages:
1. Always remember about break
2. Input data type limitation
3. Can’t get result
4. Don’t understand all possible options for enum
Old version of switch
38
Pattern matching with switch case
39
public void printObject(Object obj) {
switch (obj) {
case String s:
System.out.println("This is String" + s.trim());
break;
case Integer i:
System.out.println("This is Integer" + i);
break;
case Number n:
System.out.println("This is number"+ n);
break;
default:
System.out.println("I don't know");
}
}
40
public void printObject(Object obj) {
switch (obj) {
case String s:
System.out.println("This is String" + s.trim());
break;
case Number n:
System.out.println("This is number"+ n);
break;
case Integer i:
System.out.println("This is Integer" + i);
break;
default:
System.out.println("I don't know");
}
}
41
public void printObject(Object obj) {
switch (obj) {
case String s:
System.out.println("This is String" + s.trim());
break;
default:
System.out.println("I don't know");
case Number n:
System.out.println("This is number"+ n);
break;
case Integer i:
System.out.println("This is Integer" + i);
break;
}
}
42
Updated switch case
43
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
return switch (programmingParadigm) {
case OBJECT_ORIENTED -> List.of("Java", "C++");
case FUNCTIONAL -> List.of("Haskel");
case PROCEDURAL -> List.of("Pascal");
};
}
Updated switch case
44
public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) {
return switch (programmingParadigm) {
case OBJECT_ORIENTED -> {
System.out.println("You are master of polymorphism");
yield List.of("Java", "C++");
}
case FUNCTIONAL -> {
System.out.println("You are master of recursion");
yield List.of("Haskel");
}
case PROCEDURAL -> {
System.out.println("Try to use another paradigms");
yield List.of("Pascal");
}
};
}
45
1. Don’t need to use break
2. Can return result
3. Don’t need to use default branch if all options described
4. Input data types have limitations
Summary of updated switch
46
Java Records
47
private record Car(int speed, String manufacturer) {
}
Java Records
48
private record Car(int speed, String manufacturer) {
}
public static void main(String[] args) {
Car car = new Car(100, "Mercedes");
System.out.println(car.speed());
System.out.println(car.manufacturer());
}
Java Records
49
private record Car(int speed, String manufacturer) {
}
public static void main(String[] args) {
Car car = new Car(100, "Mercedes");
System.out.println(car);
}
-------
Output:
Car[speed=100, manufacturer=Mercedes]
Java Records
50
private static final class Car extends java.lang.Record {
private final int speed;
private final java.lang.String manufacturer;
public Car(int speed, java.lang.String manufacturer) { /* compiled code */ }
public java.lang.String toString() { /* compiled code */ }
public final int hashCode() { /* compiled code */ }
public final boolean equals(java.lang.Object o) { /* compiled code */ }
public int speed() { /* compiled code */ }
public java.lang.String manufacturer() { /* compiled code */ }
}
51
private static final class Car extends java.lang.Record {
private final int speed;
private final java.lang.String manufacturer;
public Car(int speed, java.lang.String manufacturer) { /* compiled code */ }
public java.lang.String toString() { /* compiled code */ }
public final int hashCode() { /* compiled code */ }
public final boolean equals(java.lang.Object o) { /* compiled code */ }
public int speed() { /* compiled code */ }
public java.lang.String manufacturer() { /* compiled code */ }
}
52
public abstract class Record {
protected Record() {}
@Override
public abstract boolean equals(Object obj);
@Override
public abstract int hashCode();
@Override
public abstract String toString();
}
53
private static final class Car extends java.lang.Record {
private final int speed;
private final java.lang.String manufacturer;
public Car(int speed, java.lang.String manufacturer) { /* compiled code */ }
public java.lang.String toString() { /* compiled code */ }
public final int hashCode() { /* compiled code */ }
public final boolean equals(java.lang.Object o) { /* compiled code */ }
public int speed() { /* compiled code */ }
public java.lang.String manufacturer() { /* compiled code */ }
}
54
private static final class Car extends java.lang.Record {
private final int speed;
private final java.lang.String manufacturer;
public Car(int speed, java.lang.String manufacturer) { /* compiled code */ }
public java.lang.String toString() { /* compiled code */ }
public final int hashCode() { /* compiled code */ }
public final boolean equals(java.lang.Object o) { /* compiled code */ }
public int speed() { /* compiled code */ }
public java.lang.String manufacturer() { /* compiled code */ }
}
55
private record Car(int speed, String manufacturer) {
public Car {
if(speed < 0) {
throw new IllegalArgumentException();
}
}
}
public static void main(String[] args) {
var car = new Car(-2, "Mercedes");
System.out.println(car);
}
Canonical constructor
56
private record Car(int speed, String manufacturer) {
public Car {
if(speed < 0) {
throw new IllegalArgumentException();
}
}
public Car(String manufacturer) {
this(0, manufacturer);
}
}
Canonical constructor
57
private static final class Car extends java.lang.Record {
private final int speed;
private final java.lang.String manufacturer;
public Car(int speed, java.lang.String manufacturer) { /* compiled code */ }
public java.lang.String toString() { /* compiled code */ }
public final int hashCode() { /* compiled code */ }
public final boolean equals(java.lang.Object o) { /* compiled code */ }
public int speed() { /* compiled code */ }
public java.lang.String manufacturer() { /* compiled code */ }
}
58
private static final class Car extends java.lang.Record {
private final int speed;
private final java.lang.String manufacturer;
public Car(int speed, java.lang.String manufacturer) { /* compiled code */ }
public java.lang.String toString() { /* compiled code */ }
public final int hashCode() { /* compiled code */ }
public final boolean equals(java.lang.Object o) { /* compiled code */ }
public int speed() { /* compiled code */ }
public java.lang.String manufacturer() { /* compiled code */ }
}
59
1. Java 14 present first version of pattern matching
2. Type pattern matching present in instanceof operator
3. New Switch statement was released with some blanks for
pattern matching
4. Keep eye on Java Records and deconstruction patterns
Summary
60
Thank You

More Related Content

What's hot

Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
Scott Leberknight
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - StockholmJan Kronquist
 
Comparing JVM languages
Comparing JVM languagesComparing JVM languages
Comparing JVM languages
Jose Manuel Ortega Candel
 
02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB
Hari Christian
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVM
Jarek Ratajski
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
Ganesh Samarthyam
 
Eta
EtaEta
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
Ganesh Samarthyam
 
02 Java Language And OOP PART II
02 Java Language And OOP PART II02 Java Language And OOP PART II
02 Java Language And OOP PART II
Hari Christian
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
Ganesh Samarthyam
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
Christoph Pickl
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
intelliyole
 
Kotlin meets Gadsu
Kotlin meets GadsuKotlin meets Gadsu
Kotlin meets Gadsu
Christoph Pickl
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
José Paumard
 
Strings and Characters
Strings and CharactersStrings and Characters
Strings and Characters
Andy Juan Sarango Veliz
 
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
Ganesh Samarthyam
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
Ganesh Samarthyam
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
 
JavaOne 2013 - Clojure for Java Developers
JavaOne 2013 - Clojure for Java DevelopersJavaOne 2013 - Clojure for Java Developers
JavaOne 2013 - Clojure for Java Developers
Jan Kronquist
 

What's hot (20)

Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
 
Comparing JVM languages
Comparing JVM languagesComparing JVM languages
Comparing JVM languages
 
02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVM
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
Eta
EtaEta
Eta
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
 
02 Java Language And OOP PART II
02 Java Language And OOP PART II02 Java Language And OOP PART II
02 Java Language And OOP PART II
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
Kotlin meets Gadsu
Kotlin meets GadsuKotlin meets Gadsu
Kotlin meets Gadsu
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 
Strings and Characters
Strings and CharactersStrings and Characters
Strings and Characters
 
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
JavaOne 2013 - Clojure for Java Developers
JavaOne 2013 - Clojure for Java DevelopersJavaOne 2013 - Clojure for Java Developers
JavaOne 2013 - Clojure for Java Developers
 

Similar to Pattern Matching in Java 14

What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
Sandeep Kr. Singh
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
Simon Ritter
 
JavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingJavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programming
Henri Tremblay
 
Forgive me for i have allocated
Forgive me for i have allocatedForgive me for i have allocated
Forgive me for i have allocated
Tomasz Kowalczewski
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
BTI360
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
Jesper Kamstrup Linnet
 
Nice to meet Kotlin
Nice to meet KotlinNice to meet Kotlin
Nice to meet Kotlin
Jieyi Wu
 
Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
Venkateswaran Kandasamy
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
Jesper Kamstrup Linnet
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
Łukasz Bałamut
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Yann-Gaël Guéhéneuc
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
VictorSzoltysek
 
Not your father's tests
Not your father's testsNot your father's tests
Not your father's tests
Sean P. Floyd
 
Introduzione al TDD
Introduzione al TDDIntroduzione al TDD
Introduzione al TDD
Andrea Francia
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
Muhammad Durrah
 
GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?
Patrick Lam
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
Stuart Roebuck
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Ayes Chinmay
 

Similar to Pattern Matching in Java 14 (20)

What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
JavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingJavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programming
 
Forgive me for i have allocated
Forgive me for i have allocatedForgive me for i have allocated
Forgive me for i have allocated
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
 
Nice to meet Kotlin
Nice to meet KotlinNice to meet Kotlin
Nice to meet Kotlin
 
Scala
ScalaScala
Scala
 
Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
 
Not your father's tests
Not your father's testsNot your father's tests
Not your father's tests
 
Introduzione al TDD
Introduzione al TDDIntroduzione al TDD
Introduzione al TDD
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
 
GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
 

More from GlobalLogic Ukraine

GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
GlobalLogic Ukraine
 
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
GlobalLogic Ukraine
 
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
GlobalLogic Ukraine
 
Штучний інтелект як допомога в навчанні, а не замінник.pptx
Штучний інтелект як допомога в навчанні, а не замінник.pptxШтучний інтелект як допомога в навчанні, а не замінник.pptx
Штучний інтелект як допомога в навчанні, а не замінник.pptx
GlobalLogic Ukraine
 
Задачі AI-розробника як застосовується штучний інтелект.pptx
Задачі AI-розробника як застосовується штучний інтелект.pptxЗадачі AI-розробника як застосовується штучний інтелект.pptx
Задачі AI-розробника як застосовується штучний інтелект.pptx
GlobalLogic Ukraine
 
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptxЩо треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
GlobalLogic Ukraine
 
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
GlobalLogic Ukraine
 
JavaScript Community Webinar #14 "Why Is Git Rebase?"
JavaScript Community Webinar #14 "Why Is Git Rebase?"JavaScript Community Webinar #14 "Why Is Git Rebase?"
JavaScript Community Webinar #14 "Why Is Git Rebase?"
GlobalLogic Ukraine
 
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
GlobalLogic Ukraine
 
Страх і сила помилок - IT Inside від GlobalLogic Education
Страх і сила помилок - IT Inside від GlobalLogic EducationСтрах і сила помилок - IT Inside від GlobalLogic Education
Страх і сила помилок - IT Inside від GlobalLogic Education
GlobalLogic Ukraine
 
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
GlobalLogic Ukraine
 
GlobalLogic QA Webinar “What does it take to become a Test Engineer”
GlobalLogic QA Webinar “What does it take to become a Test Engineer”GlobalLogic QA Webinar “What does it take to become a Test Engineer”
GlobalLogic QA Webinar “What does it take to become a Test Engineer”
GlobalLogic Ukraine
 
“How to Secure Your Applications With a Keycloak?
“How to Secure Your Applications With a Keycloak?“How to Secure Your Applications With a Keycloak?
“How to Secure Your Applications With a Keycloak?
GlobalLogic Ukraine
 
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
GlobalLogic Ukraine
 
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
GlobalLogic Ukraine
 
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
GlobalLogic Ukraine
 
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"
GlobalLogic Ukraine
 
GlobalLogic Webinar "Introduction to Embedded QA"
GlobalLogic Webinar "Introduction to Embedded QA"GlobalLogic Webinar "Introduction to Embedded QA"
GlobalLogic Webinar "Introduction to Embedded QA"
GlobalLogic Ukraine
 
C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"
GlobalLogic Ukraine
 
GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...
GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...
GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...
GlobalLogic Ukraine
 

More from GlobalLogic Ukraine (20)

GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
 
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
 
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
 
Штучний інтелект як допомога в навчанні, а не замінник.pptx
Штучний інтелект як допомога в навчанні, а не замінник.pptxШтучний інтелект як допомога в навчанні, а не замінник.pptx
Штучний інтелект як допомога в навчанні, а не замінник.pptx
 
Задачі AI-розробника як застосовується штучний інтелект.pptx
Задачі AI-розробника як застосовується штучний інтелект.pptxЗадачі AI-розробника як застосовується штучний інтелект.pptx
Задачі AI-розробника як застосовується штучний інтелект.pptx
 
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptxЩо треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
 
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
 
JavaScript Community Webinar #14 "Why Is Git Rebase?"
JavaScript Community Webinar #14 "Why Is Git Rebase?"JavaScript Community Webinar #14 "Why Is Git Rebase?"
JavaScript Community Webinar #14 "Why Is Git Rebase?"
 
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
 
Страх і сила помилок - IT Inside від GlobalLogic Education
Страх і сила помилок - IT Inside від GlobalLogic EducationСтрах і сила помилок - IT Inside від GlobalLogic Education
Страх і сила помилок - IT Inside від GlobalLogic Education
 
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
 
GlobalLogic QA Webinar “What does it take to become a Test Engineer”
GlobalLogic QA Webinar “What does it take to become a Test Engineer”GlobalLogic QA Webinar “What does it take to become a Test Engineer”
GlobalLogic QA Webinar “What does it take to become a Test Engineer”
 
“How to Secure Your Applications With a Keycloak?
“How to Secure Your Applications With a Keycloak?“How to Secure Your Applications With a Keycloak?
“How to Secure Your Applications With a Keycloak?
 
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
 
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
 
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
 
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"
 
GlobalLogic Webinar "Introduction to Embedded QA"
GlobalLogic Webinar "Introduction to Embedded QA"GlobalLogic Webinar "Introduction to Embedded QA"
GlobalLogic Webinar "Introduction to Embedded QA"
 
C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"
 
GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...
GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...
GlobalLogic Test Automation Live Testing Session “Android Behind UI — Testing...
 

Recently uploaded

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

Pattern Matching in Java 14

  • 1. 1 Java 14 Pattern Matching Oleksandr Navka Lead Software Engineer, Consultant, GlobalLogic
  • 2. 2 1. Updated instanceof 2. Updated switch-case 3. Java Records Agenda
  • 3. 3 Тагир Валеев JetBrains Pattern matching и его воображаемые друзья
  • 4. 4
  • 5. 5 When someone match something :) What is pattern matching?
  • 6. 6 Any pattern • _ Constant pattern • 1 • true • null Type pattern • String s Var pattern • var i = 1 Deconstruction pattern • Optional(String s) • Node(Node left, Node right) What are the patterns?
  • 8. 8 public class Animal { } class Dog extends Animal { public void bark() { } } class Cat extends Animal { public void meow() { } }
  • 9. 9 public static void say(Animal animal) { if (animal instanceof Dog) { Dog dog = (Dog) animal; dog.bark(); } else if (animal instanceof Cat) { Cat cat = (Cat) animal; cat.meow(); } }
  • 10. 10 public static void say(Animal animal) { if (animal instanceof Dog) { Dog dog = (Dog) animal; dog.bark(); } else if (animal instanceof Cat) { Cat cat = (Cat) animal; cat.meow(); } }
  • 11. 11 public static void say(Animal animal) { if (animal instanceof Dog dog) { dog.bark(); } else if (animal instanceof Cat cat) { cat.meow(); } }
  • 12. 12 public static void say(Animal animal) { if (animal instanceof Dog dog) { dog.bark(); } else if (animal instanceof Cat cat) { cat.meow(); } }
  • 15. 15 if (obj instanceof String s) { // can use s here } else { // can't use s here }
  • 16. 16 if (obj instanceof String s) { // can use s here } else { // can't use s here } binding variable
  • 17. 17 if (!(obj instanceof String s)) { } else { s.contains("a") }
  • 18. 18 if(obj instanceof String s && s.length() > 5) { System.out.println(s.toUpperCase()); }
  • 19. 19 if(obj instanceof String s || s.length() > 5) { System.out.println(s.toUpperCase()); }
  • 20. 20 if(!(obj instanceof String s) || s.length() > 5) { System.out.println("Do something"); } else { System.out.println(s.toUpperCase()); }
  • 21. 21 if(!(obj instanceof String s) || s.length() > 5) { System.out.println("Do something"); } else { System.out.println(s.toUpperCase()); }
  • 22. 22 if(!(obj instanceof String s) || s.length() > 5) { throw new IllegalArgumentException(); } System.out.println(s.toUpperCase());
  • 23. 23 if(!(obj instanceof String s) || s.length() > 5) { throw new IllegalArgumentException(); } System.out.println(s.toUpperCase());
  • 24. 24 if (!(obj instanceof String s)) { s.contains(..) } else { s.contains(..) }
  • 25. 25 private String s = "abc"; if (!(obj instanceof String s)) { s.contains(..) } else { s.contains(..) }
  • 26. 26 1. if (obj instanceof String s) {s.trim()} 2. if (!(obj instanceof String s)) {} else {s.contains("a")} 3. if(obj instanceof String s && s.length() > 5) {} 4. if(obj instanceof String s || s.length() > 5) {} Binding variable scope
  • 27. 27 1. if (obj instanceof String s) {s.trim()} 2. if (!(obj instanceof String s)) {} else {s.contains("a")} 3. if(obj instanceof String s && s.length() > 5) {} 4. if(obj instanceof String s || s.length() > 5) {} Binding variable scope
  • 28. 28 1. if (obj instanceof String s) {s.trim()} 2. if (!(obj instanceof String s)) {} else {s.contains("a")} 3. if(obj instanceof String s && s.length() > 5) {} 4. if(obj instanceof String s || s.length() > 5) {} 5. if(!(obj instanceof String s) || s.length() > 5) {} 6. if(!(obj instanceof String s) || s.length() > 5) {} else {s.toUpperCase());} 7. if(!(obj instanceof String s) || s.length() > 5) { throw new IllegalArgumentException(); } System.out.println(s.toUpperCase()); Binding variable scope
  • 29. 29 1. instanceof has got type pattern matching 2. instanceof the first java feature that got pattern matching 3. Be aware about scoping Instanceof Summary
  • 31. 31 public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL} public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { List<String> languages = new ArrayList<>(); switch (programmingParadigm) { case OBJECT_ORIENTED: languages.add("Java"); languages.add("C++"); break; case FUNCTIONAL: languages.add("Haskel"); break; case PROCEDURAL: languages.add("Pascal"); break; } return languages; } Old version of switch
  • 32. 32 public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL} public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { List<String> languages = new ArrayList<>(); switch (programmingParadigm) { case OBJECT_ORIENTED: languages.add("Java"); languages.add("C++"); break; case FUNCTIONAL: languages.add("Haskel"); break; case PROCEDURAL: languages.add("Pascal"); break; } return languages; } Old version of switch
  • 33. 33 public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL} public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { List<String> languages = new ArrayList<>(); switch (programmingParadigm) { case OBJECT_ORIENTED: languages.add("Java"); languages.add("C++"); break; case FUNCTIONAL: languages.add("Haskel"); break; case PROCEDURAL: languages.add("Pascal"); break; } return languages; } Old version of switch Input type limitations: byte, short, char, and int Enum Types, String
  • 34. 34 public enum ProgrammingParadigm {OBJECT_ORIENTED, PROCEDURAL, FUNCTIONAL} public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { List<String> languages = new ArrayList<>(); switch (programmingParadigm) { case OBJECT_ORIENTED: languages.add("Java"); languages.add("C++"); break; case FUNCTIONAL: languages.add("Haskel"); break; case PROCEDURAL: languages.add("Pascal"); break; } return languages; } Old version of switch Can’t get result
  • 35. 35 public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { switch (programmingParadigm) { case OBJECT_ORIENTED: return List.of("Java", "C++"); case FUNCTIONAL: return List.of("Haskel"); case PROCEDURAL: return List.of("Pascal"); default: return List.of(); } }
  • 36. 36 public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { switch (programmingParadigm) { case OBJECT_ORIENTED: return List.of("Java", "C++"); case FUNCTIONAL: return List.of("Haskel"); case PROCEDURAL: return List.of("Pascal"); default: return List.of(); } }
  • 37. 37 Disadvantages: 1. Always remember about break 2. Input data type limitation 3. Can’t get result 4. Don’t understand all possible options for enum Old version of switch
  • 39. 39 public void printObject(Object obj) { switch (obj) { case String s: System.out.println("This is String" + s.trim()); break; case Integer i: System.out.println("This is Integer" + i); break; case Number n: System.out.println("This is number"+ n); break; default: System.out.println("I don't know"); } }
  • 40. 40 public void printObject(Object obj) { switch (obj) { case String s: System.out.println("This is String" + s.trim()); break; case Number n: System.out.println("This is number"+ n); break; case Integer i: System.out.println("This is Integer" + i); break; default: System.out.println("I don't know"); } }
  • 41. 41 public void printObject(Object obj) { switch (obj) { case String s: System.out.println("This is String" + s.trim()); break; default: System.out.println("I don't know"); case Number n: System.out.println("This is number"+ n); break; case Integer i: System.out.println("This is Integer" + i); break; } }
  • 43. 43 public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { return switch (programmingParadigm) { case OBJECT_ORIENTED -> List.of("Java", "C++"); case FUNCTIONAL -> List.of("Haskel"); case PROCEDURAL -> List.of("Pascal"); }; } Updated switch case
  • 44. 44 public static List<String> getProgrammingLanguage(ProgrammingParadigm programmingParadigm) { return switch (programmingParadigm) { case OBJECT_ORIENTED -> { System.out.println("You are master of polymorphism"); yield List.of("Java", "C++"); } case FUNCTIONAL -> { System.out.println("You are master of recursion"); yield List.of("Haskel"); } case PROCEDURAL -> { System.out.println("Try to use another paradigms"); yield List.of("Pascal"); } }; }
  • 45. 45 1. Don’t need to use break 2. Can return result 3. Don’t need to use default branch if all options described 4. Input data types have limitations Summary of updated switch
  • 47. 47 private record Car(int speed, String manufacturer) { } Java Records
  • 48. 48 private record Car(int speed, String manufacturer) { } public static void main(String[] args) { Car car = new Car(100, "Mercedes"); System.out.println(car.speed()); System.out.println(car.manufacturer()); } Java Records
  • 49. 49 private record Car(int speed, String manufacturer) { } public static void main(String[] args) { Car car = new Car(100, "Mercedes"); System.out.println(car); } ------- Output: Car[speed=100, manufacturer=Mercedes] Java Records
  • 50. 50 private static final class Car extends java.lang.Record { private final int speed; private final java.lang.String manufacturer; public Car(int speed, java.lang.String manufacturer) { /* compiled code */ } public java.lang.String toString() { /* compiled code */ } public final int hashCode() { /* compiled code */ } public final boolean equals(java.lang.Object o) { /* compiled code */ } public int speed() { /* compiled code */ } public java.lang.String manufacturer() { /* compiled code */ } }
  • 51. 51 private static final class Car extends java.lang.Record { private final int speed; private final java.lang.String manufacturer; public Car(int speed, java.lang.String manufacturer) { /* compiled code */ } public java.lang.String toString() { /* compiled code */ } public final int hashCode() { /* compiled code */ } public final boolean equals(java.lang.Object o) { /* compiled code */ } public int speed() { /* compiled code */ } public java.lang.String manufacturer() { /* compiled code */ } }
  • 52. 52 public abstract class Record { protected Record() {} @Override public abstract boolean equals(Object obj); @Override public abstract int hashCode(); @Override public abstract String toString(); }
  • 53. 53 private static final class Car extends java.lang.Record { private final int speed; private final java.lang.String manufacturer; public Car(int speed, java.lang.String manufacturer) { /* compiled code */ } public java.lang.String toString() { /* compiled code */ } public final int hashCode() { /* compiled code */ } public final boolean equals(java.lang.Object o) { /* compiled code */ } public int speed() { /* compiled code */ } public java.lang.String manufacturer() { /* compiled code */ } }
  • 54. 54 private static final class Car extends java.lang.Record { private final int speed; private final java.lang.String manufacturer; public Car(int speed, java.lang.String manufacturer) { /* compiled code */ } public java.lang.String toString() { /* compiled code */ } public final int hashCode() { /* compiled code */ } public final boolean equals(java.lang.Object o) { /* compiled code */ } public int speed() { /* compiled code */ } public java.lang.String manufacturer() { /* compiled code */ } }
  • 55. 55 private record Car(int speed, String manufacturer) { public Car { if(speed < 0) { throw new IllegalArgumentException(); } } } public static void main(String[] args) { var car = new Car(-2, "Mercedes"); System.out.println(car); } Canonical constructor
  • 56. 56 private record Car(int speed, String manufacturer) { public Car { if(speed < 0) { throw new IllegalArgumentException(); } } public Car(String manufacturer) { this(0, manufacturer); } } Canonical constructor
  • 57. 57 private static final class Car extends java.lang.Record { private final int speed; private final java.lang.String manufacturer; public Car(int speed, java.lang.String manufacturer) { /* compiled code */ } public java.lang.String toString() { /* compiled code */ } public final int hashCode() { /* compiled code */ } public final boolean equals(java.lang.Object o) { /* compiled code */ } public int speed() { /* compiled code */ } public java.lang.String manufacturer() { /* compiled code */ } }
  • 58. 58 private static final class Car extends java.lang.Record { private final int speed; private final java.lang.String manufacturer; public Car(int speed, java.lang.String manufacturer) { /* compiled code */ } public java.lang.String toString() { /* compiled code */ } public final int hashCode() { /* compiled code */ } public final boolean equals(java.lang.Object o) { /* compiled code */ } public int speed() { /* compiled code */ } public java.lang.String manufacturer() { /* compiled code */ } }
  • 59. 59 1. Java 14 present first version of pattern matching 2. Type pattern matching present in instanceof operator 3. New Switch statement was released with some blanks for pattern matching 4. Keep eye on Java Records and deconstruction patterns Summary