Will Tollefson
Will Tollefson
  • Видео 69
  • Просмотров 82 232
Are You Using This NEW Java Feature?
In this video we'll cover the STRING TEMPLATES feature in JDK 22. One immediate benefit of this feature is that it better streamlines string interpolation, but these NEW JAVA TEMPLATE EXPRESSIONS can do A LOT more than that!
I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE!
LINKS:
JEP 459: openjdk.org/jeps/459
VIDEO CHAPTERS:
0:00 What is String Interpolation?
1:00 Why Should I Use String Templates?
1:33 Readability Improvements
4:11 Embedded Expressions
7:24 Text Blocks
9:13 Template Processors
15:31 JEP 459
17:39 Closing Thoughts
Просмотров: 424

Видео

Socket Programming with Java NIO - Channels, Selectors, and Buffers
Просмотров 1,1 тыс.3 месяца назад
In this video we'll cover SOCKET PROGRAMMING using the JAVA NIO library. We'll make an example client/server aplication where the server only requires one thread to handle multiple client connections! In the process we'll touch on CHANNELS, SELECTORS, and BUFFERS, and why byte order and ENDIANNESS matter in computer networking.Network byte order is BIG ENDIAN, but you should always confirm byte...
Java Network Sockets + Virtual Threads = Cool!
Просмотров 1,1 тыс.4 месяца назад
In this video we'll cover SOCKET PROGRAMMING in JAVA. We'll touch on both SINGLE and MULTITHREADED server applications that have server sockets waiting for client connections. Java sockets are built upon TCP, but the API also provides DatagramSocket, a UDP based implementation sometimes used in particular applications. Also be sure to stick around till near the end where we talk about the Java ...
Operator Overloading in Kotlin
Просмотров 1784 месяца назад
In this video, we'll cover how to perform OPERATOR OVERLOADING IN KOTLIN. We'll go through a few examples of operators such as addition, comparison, and indexing. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE! VIDEO CHAPTERS: 0:00 Introduction 1:11 Addition 4:36 Prefix and Postfix ...
Scoped Values in Java 22
Просмотров 8685 месяцев назад
In this video we'll cover SCOPED VALUES IN JDK 22. We'll talk about what a ScopedValue gets you vs prior ThreadLocal code examples and why you should probably migrate to ScopedValue especially int the context of virtual threads and structured concurrency. Scoped values address some of the main problems with ThreadLocal such as UNCONSTRAINED MUTABILITY, UNBOUNDED LIFETIMES, and EXPENSIVE INHERIT...
Inheritance and Solving the Diamond Problem in Kotlin
Просмотров 1845 месяцев назад
In this video, we'll cover HOW INHERITANCE WORKS IN KOTLIN. We'll go into a little bit of POLYMORPHISM as well with METHOD OVERRIDING, using the SUPER keyword and a couple corner case situations. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE! VIDEO CHAPTERS: 0:00 Introduction 0:46 ...
Structured Concurrency in Java 21
Просмотров 1,5 тыс.5 месяцев назад
In this video we'll cover STRUCTURED CONCURRENCY IN JDK 21. We'll talk about some of the differences between ExecutorService and StructuredTaskScope as well as touching on things like impacts to THREAD DUMPS. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE! LINKS: JEP 453: openjdk.or...
Kotlin Classes and Constructors - Primary vs Secondary
Просмотров 3356 месяцев назад
In this video, we'll cover how to MAKE YOUR OWN KOTLIN CLASS, including methods for customizing this with PRIMARY AND SECONDARY CONSTRUCOTRS. We'll also touch briefly on the FOUR VISIBILITY MODIFIERS IN KOTLIN. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE! VIDEO CHAPTERS: 0:00 Int...
The Abstract Factory Design Pattern In Java
Просмотров 1,1 тыс.6 месяцев назад
There are multiple variants of the FACTORY DESIGN PATTERN IN JAVA. In this video, we'll go through the ABSTRACT FACTORY PATTERN, which is a continuation of the FACTORY METHOD PATTERN with additional factory methods used to create groups of like objects. This pattern, while more complicated, can have some real benefits down the road for extendability and testability. I'm Will Tollefson, a guy wh...
Kotlin Avoided a $1,000,000,000 Mistake
Просмотров 6976 месяцев назад
Kotlin was designed with NULL SAFETY in mind, which largely allows it to avoid the major issue of unexpected null pointer dereferencing. In other programming languages, this has caused numerous issues over the years, in my opinion easily culminating in over $1,000,000,000 in costs. In this video I'll go over different aspects of Kotlin's null safety approach including the SAFE CALL OPERATOR, EL...
Virtual Threads in Java 21
Просмотров 4,4 тыс.6 месяцев назад
In this video we'll cover a relatively new feature to the Java language, VIRTUAL THREADS. We'll talk about some current BEST PRACTICES of using them and cover SIMPLE EXAMPLES of how you can use them in your code. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE! LINKS: JEP 444: openjd...
Collections In Kotlin: Intro to List, Set, and Map
Просмотров 2377 месяцев назад
Some of the fundamental building blocks of Kotlin are the language's builtin COLLECTIONS: LIST, SET, and MAP. In this video we'll go through how to make these collections and talk about some of their similarities and differences. We'll also talk about MUTABLE vs READ-ONLY variants of these collections. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned...
The Factory Design Pattern In Java
Просмотров 1,7 тыс.7 месяцев назад
There are multiple variants of the FACTORY DESIGN PATTERN IN JAVA. In this video, we'll go through the two most common adaptations, the SIMPLE FACTORY PATTERN and the (regular) FACTORY METHOD PATTERN. If the regular FACTORY PATTERN doesn't quite scratch your itch, I'd recommend you look at the ABSTRACT FACTORY PATTERN I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others w...
Getting Started With Kotlin: The Basics
Просмотров 5247 месяцев назад
Let's write our FIRST KOTLIN PROGRAM! In this video, we'll make a KOTLIN HELLO WORLD program and then introduce concepts like VARIABLES and KOTLIN's TYPE INFERENCE, also scratching the surface of Kotlin's powerful STRING TEMPLATES. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE! VID...
The Singleton Design Pattern In Java
Просмотров 7147 месяцев назад
Have you ever had to write a SINGLETON IN JAVA? They can be hard to get right - I had a few coding bugs while filming the video! There are also multiple different types between ENUM SINGLETONS, LAZY VS EAGER SINGLETONS, MULTI-THREADED DOUBLE CHECKED LOCKING SINGLETONS, the list goes on. Then there's the problem of preventing this design pattern from being broken, typically via REFLECTION. In th...
How to Create Your First Maven Java Project
Просмотров 6378 месяцев назад
How to Create Your First Maven Java Project
Java Just Got Easier to Learn and Teach | Java's New Hello World
Просмотров 1,1 тыс.8 месяцев назад
Java Just Got Easier to Learn and Teach | Java's New Hello World
Are You Using Java's Parallel Streams Correctly? - Java Programming
Просмотров 4,9 тыс.8 месяцев назад
Are You Using Java's Parallel Streams Correctly? - Java Programming
Countdown to Christmas Java Application Full Walkthrough - Java Programming
Просмотров 3748 месяцев назад
Countdown to Christmas Java Application Full Walkthrough - Java Programming
Java Annotations and How to Build Your Own Runtime Annotations - Java Programming
Просмотров 1,2 тыс.9 месяцев назад
Java Annotations and How to Build Your Own Runtime Annotations - Java Programming
How to Use JDBC to Read From a MySQL Database - Java Programming
Просмотров 6769 месяцев назад
How to Use JDBC to Read From a MySQL Database - Java Programming
Java Optionals, a Practical Walkthrough - Java Programming
Просмотров 8039 месяцев назад
Java Optionals, a Practical Walkthrough - Java Programming
Coding a Java Sudoku Solver - Java Programming
Просмотров 2,6 тыс.9 месяцев назад
Coding a Java Sudoku Solver - Java Programming
How to Really Debug Java Streams - Java Programming
Просмотров 8889 месяцев назад
How to Really Debug Java Streams - Java Programming
Reflection in Java: The Fundamentals - Java Programming
Просмотров 2,5 тыс.10 месяцев назад
Reflection in Java: The Fundamentals - Java Programming
Java's Stream API Explained - Java Programming
Просмотров 1,1 тыс.10 месяцев назад
Java's Stream API Explained - Java Programming
Checked and Unchecked Exceptions in Java - Java Programming
Просмотров 1,2 тыс.10 месяцев назад
Checked and Unchecked Exceptions in Java - Java Programming
Building a Snake Game in Java: A Complete Walkthrough - Java Programming
Просмотров 6 тыс.10 месяцев назад
Building a Snake Game in Java: A Complete Walkthrough - Java Programming
The Basics of Debugging Your Code in IntelliJ - Java Programming
Просмотров 10 тыс.11 месяцев назад
The Basics of Debugging Your Code in IntelliJ - Java Programming
Java Packages and Import Statements - Java programming
Просмотров 36411 месяцев назад
Java Packages and Import Statements - Java programming

Комментарии

  • @kangshenggoh9128
    @kangshenggoh9128 4 дня назад

    can explain garbage collector

    • @willtollefson
      @willtollefson 2 дня назад

      Do you want to know about how garbage collection works in Java in general, or specifically how it would pertain to something like a template expression?

  • @carloocarraro8829
    @carloocarraro8829 9 дней назад

    For the measure performance Instance + Duration. Good Video

  • @Leukothea
    @Leukothea 10 дней назад

    THANK YOU!!! Your video helped me understand the difference between the two after a Udemy course failed doing so. Granted, I had to pause a few times and look up more stuff that I forgot already, but now ... 🤯 And as a lover of keyboard shortcuts, the sout > System.out.println() made me incredibly happy.

  • @sashar5646
    @sashar5646 12 дней назад

    Me at the start of this video: "Ah, how simple, I understand everything." After the 11th minute: "F-ck."

    • @willtollefson
      @willtollefson 12 дней назад

      Threading issues and deadlocks can be some really interesting bugs to solve, which is why those thread dumps can be really useful!

  • @chukwumaohuabunwa
    @chukwumaohuabunwa 15 дней назад

    Detailed explanation!! Subscribed already

  • @chukwumaohuabunwa
    @chukwumaohuabunwa 15 дней назад

    For the reduce function, about what is happening. Is it (1001 + 1002 + ...) or (101 + 102 + ...) 12:32

    • @willtollefson
      @willtollefson 15 дней назад

      Good catch - its supposed to be (101 + 102 + ...). I must have had the number "1000" in my head. Thanks for noting that!

  • @duparcg
    @duparcg 18 дней назад

    filenotfound should really be unchecked because you have to run the code for it to see that the location is wrong for instance... very weird

    • @willtollefson
      @willtollefson 17 дней назад

      A checked exception doesn’t necessarily mean an error can be detected at compile time or not (otherwise the compiler would just flag it right away). It just means that you have to provide explicit error handling code. Both checked and unchecked exceptions represent errors that can occur at runtime. The merits of checked exceptions are debatable, but among other checked exceptions, this one makes sense to me because there is reasonable likelihood of code hitting a case like this and you should have specific handling code available for it. Hopefully that helps clarify it a bit!

    • @duparcg
      @duparcg 17 дней назад

      @@willtollefson thank you

  • @duparcg
    @duparcg 18 дней назад

    great video

  • @gurdarshanbrar
    @gurdarshanbrar 27 дней назад

    how do i keep playing again without quitting once started? i need to know for my assingment.

    • @willtollefson
      @willtollefson 26 дней назад

      You can use another while loop to do that. For example if you want to keep the number range the same each time but select a different random number for each iteration, you could add a while loop around line 12.

  • @dipeshbisht8516
    @dipeshbisht8516 29 дней назад

    this needs more views. Great Explanation , thank you

  • @nikhilsinghal7542
    @nikhilsinghal7542 Месяц назад

    Thank you so much it helped a lot

  • @ethanhunt937
    @ethanhunt937 Месяц назад

    Phenomenal

  • @ozgunkarzan5163
    @ozgunkarzan5163 Месяц назад

    Great explanation!

  • @vamshikrishna1365
    @vamshikrishna1365 Месяц назад

    Really enjoyed this tutorial! Great job man!

  • @shalabhful
    @shalabhful Месяц назад

    Great content! one suggestion on positive side, sometime your voice is not very clear and feels like you are too tired.

    • @willtollefson
      @willtollefson Месяц назад

      Thanks for the comment and suggestion! Admittedly I sometimes do my filming late at night because there often aren’t enough hours in the day. I’ll do my best to get better at this 🙂

  • @user-sw3mh1ls3b
    @user-sw3mh1ls3b Месяц назад

    Its cool feature definatly I will use but there are people in my company who would revert my code and use jackson instead to create json Don't know how to deal with foolish people specially when the have power and evil intension against you

    • @willtollefson
      @willtollefson Месяц назад

      Sometimes adopting new ways of doing things takes time. In this situation they aren’t adding the feature in its current state to the language and will probably preview an updated version in a later JDK. Hopefully you can reason with the other folks at your company one way or the other. I’ve often found logical reasoning works well for programmers that program computer logic everyday 🙂

    • @user-sw3mh1ls3b
      @user-sw3mh1ls3b Месяц назад

      @@willtollefson Thanks but sometimes you find yourself in a place where stubbornness prevails over rationality and logical reasoning. But it good these days we have people like you who help others to stay up to date with their videos and other content

  • @rikikem5553
    @rikikem5553 Месяц назад

    Brilliant tutorial !! Thanks to this video, I think I can aim for Java silver!

  • @vd-ösnd
    @vd-ösnd Месяц назад

    Thanks a lot ! The best simple explanation I found about how to start debugging in Java. Clear, concise, straight to the point!

    • @willtollefson
      @willtollefson Месяц назад

      Glad to hear you liked it! Debuggers can be very useful for sure

  • @NatiShen
    @NatiShen Месяц назад

    Are you planning on doing Spring tutorials in the future?

    • @willtollefson
      @willtollefson Месяц назад

      That depends. Do you want to see Spring tutorials? 🙂

    • @NatiShen
      @NatiShen Месяц назад

      @@willtollefson of course !!! There are no good ones online. You explain the best both for new programmers and more advanced.

    • @willtollefson
      @willtollefson Месяц назад

      I'll be sure to get to this when I can! I've been taking a short break recently while I have a very little one at home, but I hope to get back into a more regular posting schedule in the future!

    • @NatiShen
      @NatiShen Месяц назад

      @@willtollefson thanks a bunch

  • @abdullahkhaled6162
    @abdullahkhaled6162 Месяц назад

    It will removed in the future releases :(

    • @willtollefson
      @willtollefson Месяц назад

      Yeah, it was a good concept, but unfortunately had some design flaws that they are working out now. Hopefully it will have a come back in another preview coming up

  • @armaulan
    @armaulan Месяц назад

    Great Tutorial ! Greeting from Indonesia

    • @willtollefson
      @willtollefson Месяц назад

      Greetings! Thanks for the comment 🙂

  • @vasylvch9320
    @vasylvch9320 Месяц назад

    +++

  • @user-fh1mx6pz3r
    @user-fh1mx6pz3r Месяц назад

    can someone from another network join the chat with this method

    • @willtollefson
      @willtollefson Месяц назад

      If I’m understanding your question correctly, you would need to setup a public IP address with this method that is reachable to other networks and as long as you had network connectivity and the same socket protocol, you should generally be able to communicate.

  • @UmaVatsan
    @UmaVatsan Месяц назад

    Perfect !!!

  • @rajmaharjan5437
    @rajmaharjan5437 2 месяца назад

    I am so glad I found this channel!

  • @Egor_Phyl
    @Egor_Phyl 2 месяца назад

    Great explanation!

  • @Mat-qj4sg
    @Mat-qj4sg 2 месяца назад

    I don't usually write comments, but of all the videos about lambda I've watched, it was yours that made it clear to me. Thanks buddy, have a good day.

    • @willtollefson
      @willtollefson 2 месяца назад

      Awesome, glad to hear it!

    • @maaaciek5
      @maaaciek5 10 дней назад

      @@willtollefson Hey, I strongly agree with Mat. I don't write comments either, but finally now I understand lamdas... It's strange that you have so few viewers with such a great content. Thanks a lot!

    • @willtollefson
      @willtollefson 9 дней назад

      That’s great! Maybe over time I’ll get more views, but I’m not in any rush. I’m glad to hear that the content is helpful!

  • @lucap3741
    @lucap3741 2 месяца назад

    hey man really nice teeth

    • @willtollefson
      @willtollefson 2 месяца назад

      Thanks! When I see my dentist in a few months I'll be sure to thank him :)

  • @gagangupta1255
    @gagangupta1255 2 месяца назад

    Awesome tutorial

  • @titoluzuriaga8217
    @titoluzuriaga8217 2 месяца назад

    Great video. Regarding 9:45, because it's an object reference then it's not cached by the thread? Is it always reading from the heap (or L3 perhaps)?

    • @willtollefson
      @willtollefson 2 месяца назад

      Since its an object reference, the local variable value (e.g. the reference value) is cached, but the object data itself remains on the heap, so as long as you don't change the object reference, you'll still reference the same heap data across all of the threads. This is why its preferred to mark the object reference as immutable because that helps give you guarantees about the concurrent protection of the value. It doesn't, however, guarantee concurrent modification protection of the underlying object, which is why we're using AtomicInteger.

    • @titoluzuriaga8217
      @titoluzuriaga8217 2 месяца назад

      @@willtollefson thanks, I'm surprised because if I understand correctly then objects are always read from the heap and the cost is significantly higher.

    • @willtollefson
      @willtollefson 2 месяца назад

      Great point. The JLS (to my knowledge) doesn’t specify any sort of read optimizations in this type of situation. Something like that could probably be implemented per JVM if it can detect situations where a more efficient read can happen on an object reference (and I’m sure it does)

  • @NatiShen
    @NatiShen 2 месяца назад

    Hi will. Can you do an advanced video about threads, synchronised, volatil etc ?

    • @willtollefson
      @willtollefson 2 месяца назад

      Thanks for the comment! Here are some videos I've done on those topics: Volatile and atomic: ruclips.net/video/31s_DzrkqZc/видео.html Synchronized: ruclips.net/video/FpNRXz696ZY/видео.html I've also done a few videos talking about runnables in general, virtual threads, and structured concurrency. If those don't scratch the itch, let me know and I can do a video on a specific threading topic.

    • @NatiShen
      @NatiShen Месяц назад

      ​@@willtollefson Great videos.

  • @jorgemt9
    @jorgemt9 2 месяца назад

    Great video, explanation and easy to understand, keep up the good work 👍

  • @senorgriffin6405
    @senorgriffin6405 2 месяца назад

    you're awesome man, you should have way more suscribers and views

  • @ivanchl
    @ivanchl 2 месяца назад

    Amazing motto Never Stop Learning!

    • @willtollefson
      @willtollefson 2 месяца назад

      Thanks! It’s definitely something I try to follow almost every day

  • @user-nk6fq6dz6h
    @user-nk6fq6dz6h 3 месяца назад

    Thank you! Really simple it seems, haven't had to use one yet until now for my personal projects, and it seems like the Semaphores meet my needs easily. I was worried that I would've needed something more complex. Did you ever get around to making that lock video? I am going to be watching some of your other concurrency videos soon though to see what the other solutions look like.

    • @willtollefson
      @willtollefson 2 месяца назад

      That lock video is on my short list right now of future videos to make. There are multiple flavors of locks - if there's a particular thing you want me to cover in that video, let me know!

  •  3 месяца назад

    Great stuff man! I really find your explanations very useful. Thanks for sharing

    • @willtollefson
      @willtollefson 3 месяца назад

      You’re welcome, thanks for the comment!

  •  3 месяца назад

    Very good examples. Thank you very much for sharing

  • @Shuvooa
    @Shuvooa 3 месяца назад

    Please don't use `var`. It irritates the mind.

    • @willtollefson
      @willtollefson 3 месяца назад

      Personal preference I suppose 🙂 I know folks who use it every chance they get and others that wish it was never added to the language. What are your thoughts on it? I agree with a lot of what is stated here: openjdk.org/projects/amber/guides/lvti-style-guide

  • @ymetelkin
    @ymetelkin 3 месяца назад

    It takes 1.3 seconds on average to run 100,000 concurrent "1 second sleep" tasks in Go. This is 4 times faster than in your example. Is it expected? I didn't run Java version on my machine (I don't have it), but my laptop is not a super computer by any means. And just for the fun of it, I ran with 1M concurrent tasks and it took 3.1 seconds on average. And then, for even more fun, I ran it with 10M tasks; finally it was slower than 5 seconds, 11 seconds to be exact. I wonder if you can try your code with 1M tasks and share your results.

    • @willtollefson
      @willtollefson 3 месяца назад

      Thanks for the comment! When I run 1M tasks on my machine with the Java version, I'm getting 10-11 seconds. When I run similar Go code on my machine I'm getting around 5 seconds. Without deep diving the compiled byte code and go binary to really figure out the performance difference, I have a few upfront guesses: 1. Java warm up could be playing a small role here due to lazy initialization for things like the classloader and virtual threads mapping to platform threads 2. Java and Go have different default behavior for the number of routines that can be executed in parallel and the number of OS threads available to the runtime for scheduling. 3. Goroutines are optimized to have a small stack size at the beginning of execution and then expand as needed. I'm wondering if stack allocation for Java virtual threads is more expensive in this case. Both are still MUCH better in this example than the previous Java thread model though :)

    • @ymetelkin
      @ymetelkin 3 месяца назад

      Sleeping for 1 second is probably not a very realistic example and goroutine smaller starting stack may explain the difference

  • @voimalaitos
    @voimalaitos 3 месяца назад

    Thank you for your detailed videos! Any chance creating one about the classloader?

    • @willtollefson
      @willtollefson 3 месяца назад

      Sure! I'll need to do a refresher myself on some of the lower level specifics, but I think this is a great idea

  • @fzycold8652
    @fzycold8652 3 месяца назад

    Great video! Could you please do a video about daemon thread, and thread interrupt exception. If there is, I haven't seen it.

    • @willtollefson
      @willtollefson 3 месяца назад

      Thanks for the comment! Yes I can do a video on that. I haven't hit on that subject yet

  • @VigneshBhaskar
    @VigneshBhaskar 3 месяца назад

    Thanks a lot. Subscribing now..

  • @zeppelinmexicano
    @zeppelinmexicano 3 месяца назад

    Thanks for reminding us that there is a such thing as over-designing things and making them more difficult to manage and read. But the decoupling concept is quite well explained and important.

    • @willtollefson
      @willtollefson 3 месяца назад

      You bet! It’s a difficult balance to maintain for sure

  • @hristoistoyanov
    @hristoistoyanov 3 месяца назад

    String templates will not ship in its current state, and was dropped for JDK23

    • @willtollefson
      @willtollefson 3 месяца назад

      Good point - I probably should have mentioned that :) Per what I’ve seen from Brian Goetz they are reworking it and as of now planning some API changes that will make it into future versions. There are pros and cons to trying out preview features and this is why they call them previews. Glad we’re making the changes now though rather than having them in the main language

  • @DenaTollefson
    @DenaTollefson 3 месяца назад

    The string templates feature looks awesome, Will. Excellent video showing this new capability!

  • @zeppelinmexicano
    @zeppelinmexicano 3 месяца назад

    You hit quite a few good points in one short vid.

  • @zeppelinmexicano
    @zeppelinmexicano 3 месяца назад

    Crucial info for those getting unexpected results from their stream. I hope Netbeans debugger will give me this view as well.