DiscoverCoders Campus PodcastEP53 – Intro to Streams in Java
EP53 – Intro to Streams in Java

EP53 – Intro to Streams in Java

Update: 2021-11-19
Share

Description


GitHub link here: https://github.com/tp02ga/FunWithStreams


In this episode we'll talk about:



  • What are streams and why you should care about them

  • Comparing a simple Stream example to a Looping example

  • Intermediate vs Terminal operations


 


Episode Transcript


0:09

Welcome to the coders campus podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know to master the art of programming. And now, your host, Trevor page.


0:28

Oh right, ladies and gentlemen, fellow coders. Welcome back to this next episode of the coders campus podcast, we have hit episode 53. And in this one, as promised, we are going to dive into the topic of streams, which is, I have to say, it's one of my favorite topics. Because of the features that we get to leverage here that again, come from Java eight, we get to, you know, leverage lambdas. And the behaviors that we get out of this code, the things that we can do with streams, the way the code is written, it's just, it's just so much more elegant, it's just so much more beautiful, more readable. Although it takes there's a bit of a learning curve that goes along with it. Once you understand streaming, it's just so wonderful to use. And it, it's a game changer, in my opinion in terms of readability, right and simplicity, right. So but again, all of that is, you know, important to understand that before you can do all that you need to learn this stuff first. So there is a learning curve involved here.


1:38

But my God, guys, it's so much it's so worth it, it's so worth the pain in the struggle to fully understand how to use streams. Because, you know, in my opinion, I never want to go back. So now, obviously, what do I mean by that? What do I mean by going back? And what is a stream? And how, how, why should we care about them? And you know, how do we compare a stream example to something else? And you know, what are the some of the commonly used methods and whatnot that we have with respect to streams, that's sort of what we're gonna be diving into, in today's 53rd episode of this coders campus podcast. So, as always, this podcast is brought to you by V coders campus boot camp. So I'm sure at this point, you've probably heard of it. If not, hey, there's always a first time for everyone. So the coders campus boot camp provides you with all the education that you need to get a job as a coder. And it's not just the education, it's all the copious amounts, the insane amounts of support that goes along with education because education by itself, in my opinion, I know this is a little controversial, is useless. So if you are someone who is fairly new to coding, education alone is in my opinion, useless. Because going from zero, like on a scale of zero to 100, if you're going from zero to like one as a coder, where 100 is job ready, so to speak, and zero is completely not job ready, going from zero to one is so, so hard, right? That's what this this whole podcast is driving towards is just the education alone, it takes so much time and effort to go from like zero to one, as a coder, there's so much so much fundamental stuff that you need to understand and that needs to click, and you probably need to hear it in 10 different ways. And it's just so difficult, right? Unless you are naturally gifted, in which case, it's a lot less difficult. But for the average person, it's very difficult. So that's where this bootcamp helps, right? We take you from we try our best to go from zero to one, I prefer to have someone who already is at one out of 100 with respect to their coding abilities, meaning you already have been exposed to variables and you've already written small console applications. And and maybe you're you've written some methods to take in inputs and give outputs and you understand the basics of methods and variables and whatnot and some data types. Once you're there, once you have all that knowledge, that's where we can take you from one to like 100 Right. In other words, we can get you the job ready in a short period of time in the boot camp by short period of time, I mean six months, okay, that is a short period of time when you know compared with anything else. So that's what the bootcamp is all about. We give you not only the education, but all the support that you need to get from essentially hypothetically speaking, zero to 100 Ideally from one to 100. So, we take you from where you are to being job a job ready coder. So that's what the bootcamp is all about. And that is what allows me to help produce this content. So if you are interested in that if your goal is to get a job as a coder, please check out coderscampus.com/bootcamp. Okay. coderscampus.com/bootcamp that will allow you to learn more about the boot camp, the program itself, what is expected of you in terms of time commitments and whatnot. It is a part time commitment, but it's still a commitment. So if you don't have at least 20 hours a week in your schedule, then don't even think about it. It this is, you know, we have to do a lot of work in six months. So you can check that out coderscampus.com/bootcamp, it is of interest to you feel free to apply. And you can ask all the questions you like, once you've applied, you are able to book a phone call with us. And we can hop on, you know, a phone call or zoom or something. And you can ask all the questions to see, you know, make sure it's a good fit for you and vice versa, make sure that you're a good fit for the bootcamp. So at a 90 96% job placement rate for graduates within six months, this is a very successful program. So for those of my students who graduate yet 96% of them are placed within six months, most are placed within like a month or two, I would say 80% are placed within like a month or two. And that is just because of the the curriculum that we provide, as well as the level of support that you get inside of the boot camp. It is, in my opinion, top class top rated. So we pride ourselves on that education and that support. And we pride ourselves on that 96% outcome number. So like I said, if your goal is to get a job as a coder, check it out coderscampus.com/bootcamp. Okay. Sweet. So let's get into streams, because like I said, my favorite topic, or at least one of my favorite topics. So first, we will dive into what streams are and why you should care about them. So streams were introduced in Java eight, just like lambdas were introduced in Java eight, which we've been talking about in the past few episodes here on the podcast, and


6:55

what are they? Well, they are essentially another way to iterate through collections. Okay, so what that means in plain English is usually you loop through some sort of a data structure that you may have in your typical, you know, workflow when you when you are writing programs when you're writing code. So in Java, a collection is something like a list or a set or a map, or you know, who knows any combination of those or variation of those.


7:28

A collection is just a bunch of objects crammed into one data structure. And typically, you iterate through them. So typically, it's a for loop, where you you loop through each and every one of the items in a list are the items in a set or the items in a map, you iterate through them so that you can perform some sort of action, right? So for example, let's say, you know, you have a typical example I would go to is user login, right. So if you have a list of users, so you got a bunch of users, and you want to, you know, validate that the user credentials that you've been given, in other words, credentials being username and password, you want to iterate through all the users to see if this, this username password matches with what you have in your database, right in your collection, your list of users or something, or maybe a map, you know, where the key value, I don't know, whatever. This is very common, right? Or maybe you're iterating through a list of bank transactions, you want to go through all your recent bank transactions, so that you can, you know, add up the totals or something, you know, this is very common, right, you do it in a for loop it for each loop type thing. So start with the first transaction, start with the first user, go through each and every one and do something as you are iterating. And going through each one of those objects, each one of those elements in the collection. So in the list or the set or the map, or the whatever collection is just another word for a data structure that holds many other objects inside of it. Right? Go back to your episode on data structures, if you don't know what data structure is, if you don't know what a data structure is, yeah, you're definitely maybe too advanced. This episode may be too advanced. But yeah, so that's what we used to do. That was sort of the old way, we would just iterate using a for loop or something. Could be a while loop as well, any loop you would iterate through, right? Well, what streams allows us to do is more or less the same thing. We can instead of you know, doing using a for loop, we can now use a stream to iterate through our collections. Okay, now, a stream is a lot more advanced than a standard for loop. There's a lot of optim optimizations inside of it. There's a lot of, you know, stuff, low level stuff that I don't want to cover in this podcast because in my opinion, you don't really need to know that stuff to be a great coder. Those are all like interview type questions. And again, I t

Comments 
00:00
00:00
x

0.5x

0.8x

1.0x

1.25x

1.5x

2.0x

3.0x

Sleep Timer

Off

End of Episode

5 Minutes

10 Minutes

15 Minutes

30 Minutes

45 Minutes

60 Minutes

120 Minutes

EP53 – Intro to Streams in Java

EP53 – Intro to Streams in Java

Trevor Page