In this episode we'll talk about 7 common Functional Interfaces that Java provides to us.

UnaryOperator, BinaryOperator, Supplier, Consumer, Function, Predicate and BiPredicate

 

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.

0:24
And now, your host, Trevor page. All right, ladies and gentlemen, fellow coders. Welcome to Episode 52 of the coders campus podcast. As always a pleasure to be here, again, bringing you the knowledge that you need to succeed as a coder. So on that vein, as per last episode, just want to preface this by saying, if you haven't checked out the boot camp, yet, we have cohorts launching every single month. And if your goal is to get a job as a coder in as little time as possible, within reason, we're not talking about, hey, do this little thing. And in two months, you'll be getting a job with 100,000 notes. So we're a lot more realistic here at coders campus. So yeah, our boot camps are about six months in duration, we have a very high success rate. But yeah, we'll talk more about that at the end of the episode. So if you haven't already checked it out, coderscampus.com/bootcamp if you're interested in launching your career as a coder. Alright, so now into the content. For today's episode, we are continuing our talk on functional interfaces. We mentioned in the last episode that there were some popular functional interfaces that are provided to us by the good folks at Java at I guess Oracle owns it currently. And these functional interfaces that are provided to us are quite useful. So much so that like I had alluded to in the previous episode, we don't tend to create our own functional interfaces, we only tend to leverage the existing ones. So obviously, let's talk about the existing ones that are out there, in no particular order. But these are the popular ones, there are many more than the sort of five that we're going to be talking about today. But the the, the the other ones are sort of variations of these five that we're going to talk about. So once you know and understand these five, the rest of them tend to be

2:27
fairly straightforward to understand. You'll see them and say, Oh, that's a variation of one of the five that Trevor taught me and I get it right. So let's start with the first with the five. Let me see is it 512345667? Sorry, I've been saying five, seven.

2:45
Although anyway, we'll dive into the popular ones. So again, just a recap, in case you Well, if you missed the last episode, go back and listen to it. Because if you don't want to functional interfaces, you're going to be entirely lost with this conversation right now. So highly recommend going back to the previous episode to listen up and learn about functional interfaces. But the first functional interface that we will talk about

3:11
is one called the predicate. Now these names are terrible, in my opinion, I hear the word predicate, and I'm sure maybe some people it clicks and make sense, it still hasn't clicked in my brain yet. But predicate is the name of this functional interface anyway, and it takes one generic type T. Okay, so this is a throwback to generics, hopefully you understand what generics are. Very quick recap of generics, you can think of these single capital letters that are known as generics usually encased in the angle brackets. For example, if you see a list, so give a list of something like a list of strings. The other is usually I say, of, but I you write out the angle brackets, so less than and greater than symbol. And in between those less than greater than symbols, you put the type. So in this case, if you have a list of strings, you would say list, open angle bracket, and you would put string as a data type, and then you close the angle bracket. And then you could instantiate that list with as an array list of strings or, or it could be a list of, you know, any object can be a list of double, it could be a list of user, it could be a list of anything. The point is the of their the word of typically means generic, right? It's a list of something. And that could be anything therefore that anything can be generic. Previously, you would use just the object type. Okay, object would be what you would throw in there, but then you need to cast it all the time, you'd have to cast object to your desired type. And casting can be a little bit wonky at times it can cause issues and it's just a it's just more mess. So Java introduced generics in, I think, version five or something. I've done an episode on generics. So if you don't know what generics are, I would obviously recommend brushing up on that as well. Now

5:00
That's all I will say about generics getting back to these functional interfaces, specifically the predicate functional interface. predicate takes one type T. Okay, so it uses generics a generic type. So it takes a single parameter, okay with this single type,

5:21
and it returns a Boolean.

5:25
So it has one input to its method.

5:29
And it has a return value of Boolean, so it returns a Boolean.

5:35
Okay, so this is like a framework, this is a very generic function, right? That's so you can think of these functional interfaces as as like, sort of templates for functions that are generic that you can just use. Because think of any function that you've written in the past, have you ever written a function that took in a single parameter and then returned to Boolean? I'm sure you have written a function that does that, for example, I've written one called validate user before in some of my projects, right? You want to validate a user. So you take in a user object, and inside of that user object, which has a type, there's a, you know, a username and a password or something. And then you take the username and password and you compare it against your database to see if this user exists in the database. If it does, does the passwords match exactly. If they do, then you return true. This is a valid user, or you return false. This is not a valid user. Right? So that's single

6:31
example of validate user as a as a method of function. That could be classified as a predicate. That's what predicate is all about. That's the generic, you know, functional interface that Java gives to us this generic template that we can leverage

6:49
in a bunch of places. One common place that you would use a predicate is in something called filter. So filter is something that comes with streams, we'll talk about streams, after we've done with this lesson, most likely.

7:04
filter allows us to filter out items from a collection. So if you have a list of users, and let's say in that list of users, you only want to be you only want to consider users that are active or something as an example, you only want to look at active users, active users can be defined as anything, but let's define them as you know, users that have paid their bill, right. So they're not, they haven't failed payments, or something like that, I don't know. So that the users in your system are active, and you only want to look at the active users, how you would do that is you would you would get a collection of all users. This is one way of doing it. You can have a collection of all users and then you can filter out the ones that are not active. So what filter does is it takes a predicate filter is a function that takes a predicate as its input. Okay, this is where in the past episode, I was talking about how the concept of functional interfaces and the introduction of functional interfaces here allows us to treat functions as parameters. Right? This we couldn't do this before. In the world of Java, you couldn't pass a function as a parameter to another function. Right? That's just it couldn't be done. You couldn't you can't do that. Now that became popular in JavaScript. And I'm sure other languages as well, other functional languages. And then Java, like I said, before, copied it shamelessly copied it and said, Hey, look at this great new feature that we have, are we the best? So yeah, this is what's happening here. The filter function takes another function in this case, functional interface as a parameter, and more specifically, it takes the predicate functional interface as a parameter, okay? Because the predicate takes in a type and returns a Boolean, right? So you filter out users that are that are not active, the filter method would take in a predicate, and the predicate would be you pass in a user, as, you know, part of your collection of users that you have, like, say, you have a list of users, you take in the user, that's your input. You type input type is user and the individual users in the collection, the list of users are what is being fed in one at a time, and the output is true or false. So in this case, you would sit you you know, write some code to see is this user active or not. So you would return true if the user is active, you would return false if the user is not active, that's a predicate right and that allows us to use this lambda syntax with the filter function. You know dot filter is a function, the input to the filter is this predicate and remember predicate is a functional interface. Therefore, you can use the lambda

9:56
which call it syntax. So filter can take

10:00
In a function so to speak, you type in the lambda syntax. So filter would, you know, you pass in a user, so user would be on the left, because it's your single

10:09
input value, you don't even need round brackets around that, believe it or not, when you have more than one input type with the lambda syntax. If you have more than one input type to the method, then you have to use your round brackets. But believe it or not, you can drop the round bracket. So you can just have dot filter, open up the round bracket for the filter function. And then just type in the single word user. Now you can call that word, whatever you like, it's just the name of the variable that's going into the input, the methods input, the method being the predicates, method, whatever that's called I forget, if it's like apply or might not be apply, I forget what it's called in there. But it doesn't matter, you don't have to know the name of it. There's a single public abstract method inside of the predicate functional interface. And it doesn't matter what the name is, because there's only one method and we Java knows, that's the method that we are executing here. And that method takes in one parameter of type t, and it returns a Boolean, that's what the predicate does, that's what the I should say, that's what the method inside of the predicate functional interface does.

11:14
Okay, so going back to dot filter, so you have dot filter, and then you're using the open bracket for the dot filter method, and then you pass in whatever parameter you want, whatever name of variable you want, since we are talking about iterating, through users here, again, this is I'm talking about it from a streams perspective. So if you haven't learned about spring streams, yet, there's a, there's gonna be a void, there's gonna be a gap in your knowledge as to what I'm talking about. But don't worry about that. Let's just focus on the filter here. And let's assume that we can have an input in here, and it's going to be a user. So you put in the word user, because that's what we have as an input. And then you have your arrow, minus sign greater than symbol. So on the on the right hand side is the body of the method that's going to return something returned, specifically a Boolean. So you can write whatever code that you know, you can just write user.is active, maybe you already have a method that's associated to finding out whether or not a user is active or not. And maybe that function is called user.is. Active, maybe it's, you know, a method in the user class. Okay. So that's all there is, you'd have on the left hand side, you have user and then you have the arrow, and on the right hand side, you'd say user.is. Active. And that's it. That's all the code you write, and then boom, the filter just works. Okay, because we're leveraging the predicate functional interface. And the filter takes the predicate functional interface

12:31
as its input, right filter takes that functional interface as its input, and how do we use functional interfaces? In Java? Well, we can use this great lambda syntax, this very non verbose, this very succinct

12:46
syntax, right user on the left arrow, and then user dot get, or user is active on the right of the arrow, and then that's it. You close your whatever, filters, round bracket, and you're done. Okay.

13:00
So that's where it's good. You can you can give this sort of this functionality, this filter functionality could have been anything. It could be any predicate, it could be any function that takes a single parameters input and returns any Boolean as output. That's it, it you can put whatever you like, in there, right? So it's a very, very flexible, that's the whole point of this stuff is it's flexible, and synced. If you've ever used JavaScript, I know I keep harping on this. If you've ever used JavaScript, you will you will be familiar with this, because it's just a very quick and easy and once you understand it, it's like yeah, why? Why? How would you ever not use that syntax? Right? So it just, it's just really good. I really like it. Okay. So predicate, that is one of the most common functional interfaces that Java provides to us.

13:50
Okay, now, here's its partner a little bit less common, but will take me two seconds, hopefully to explain to you there's something called by predicate

14:01
by predicate what is a by predicate, less common than predicate, but it's very easy to explain because it just takes two arguments, and returns a Boolean.

14:13
Okay, the two arguments it takes in I believe, are just type t, I think they have to be of type T. And that's it. unless I'm mistaken. But I again, I don't use my credit a lot. But yeah, it's less common. But it's very easy to understand instead of taking one argument, in other words, instead, instead of taking in like one user, and then checking to see whether or not the user is active or not, this one could take in to the by predicate takes two. So pain, it could be, you know, takes two users and you're doing something else instead of filtering out your I don't know you're doing something else for taking in two users and doing something with those two users.

14:46
Yeah, by predicate, less common, but there you go. Pretty simple to understand. When would you need to take in two arguments and return a Boolean? I don't know. That's you. I'm sure you can spend it. You can probably look through existing

15:00
code and find some use case for that. Right? So it's there, it's there if you need it. Now the question is, actually, I'm gonna pause because I haven't done any research on on the by predicate to see if it extends predicate or if it's some sort of maybe I can do it on the fly here.

15:16
Okay, sorry. So the by predicate takes in two different types, my apologies. That is my misunderstanding. So I was thinking about that when I was saying it out loud. I was like, it takes in two, two parameters, but they have to be the same type. It didn't feel right to me, which is why I may want to double check this. So no, it takes in two different types. T is the first type and you as the second type for the second argument. Okay, it's just there generics, right. You could take, you could pass in the same two types, I guess. But yeah, there you can, it gives you the flexibility of having two completely different inputs. But the point is, it returns a Boolean back. Now the other question I was thinking is, is this some sort of

15:58
extension of predicate does it extend predicate, and I don't see anything on the screen at the moment, as I'm going through here, to see that it does extend predicate. So my assumption then is that the by predicate has its use cases outside of something like the dot filter. So for dot filter, I don't believe you would be able to use by predicate. And I could code that out in front of myself to check that but I'm pretty sure it's, it's a completely different type.

16:32
Because I don't see anything in the documentation as I'm going through it.

16:36
That indicates that it is a

16:40
an extension of predicate so okay.

16:43
This is this is the to, to mid to mid specialization and predicate, whatever that means to arity is that I've never heard that word before. Anyway, these these

16:57
Oracle documentation words, this is why these podcasts exists, right? Because it's so hard to understand the the documentation. So if you have problems understanding, Docs, you're not alone. Okay? Back to it. So that's predicate by predicate. So the next one is called the unary, or unary. Operator. Okay, so the unary operator takes one parameter of type T. Okay, so just like the predicate, so we're very close here in terms of similarity, right, where they both take in one parameter of type t, but this one returns a value of that same type T.

17:37
So that's the difference, the predicate will return a boolean, this one returns a value of that same type generic type T.

17:47
Okay, so can you think of any method that you've ever created any function I'm using the word function and method to be mean that the exact same thing? I, I'm in the habit of using method because I came one of my most,

18:00
not most, what's the word I'm looking for? One of my first languages I worked with, and was most in depth into knew the most about was Visual Basic, and they call the methods.

18:10
That's the one I more or less started with was Visual Basic. So yeah, that's where this this terminology of methods comes from. When I say method, I'm trying to save function more often. So

18:23
the unary operator takes one parameter of type T and returns a value of that same type. So can you think of a function that takes in a parameter of whatever single type generic type t, and will then return that same type?

18:39
There's tons and there's tons and tons and maybe if you can't think of one off the top of your head right now, it's because there's so many I scoured I look for a really common one, a common one is replace all. So it's part of, if you have, I guess, a collection of strings or something along those lines, or a string, you can use a dot replace all. And in one of the iterations of Java, you can use Replace All that takes in a unary operator functional interface as its input for the method.

19:10
Okay, so the dot replace all takes in

19:15
a type A single type t, which in this case is a string,

19:20
and then returns that same string again.

19:24
Right, so it returns the same type does it return true or false? It returns the same type that was inputted inputted into it. So if the string comes in as input, the string goes out as input. If it's an integer that comes in as input, the integer goes out as input. If it's a double that comes in as input, it's a double that goes out as input. If it's a user that comes in as input, it's a user that goes out as input, you get the idea, right? That's what the unary operator is unary meaning one, singular, you know, one type T goes in one type T goes out. Okay? So, if you've ever tried to do a replace all on a string, you want to replace all the you know,

20:00
commas with spaces or you want to replace all the line breaks with tabs, or you want to replace all the tabs with line breaks, or you want to replace all the tabs with comma, right, whatever the case may be, whatever you want to replace.

20:15
You, you take the string as an input, and then you can send the string back as an output. Same thing, right. So that's the unary operator. Now, along the same line, just like before,

20:27
there's something called the binary operator unary, or unary, whatever operator, binary operator,

20:37
any ideas, any any thoughts as to what's going on here?

20:43
It represents, let me just go back to my notes here, I want to make sure I get this right, I don't want to make a mistake, it takes two parameters of a single type, and returns a value with that same type. So it's not two different types here, the binary operator I just double checked. So it's not like by predicate the by predicate allows you to pass in types T and type u, which is two different types. The binary operator

21:09
gives you Sorry, I'm going back gives you one single type that you can work with.

21:14
Okay, so

21:17
it's all type t, here. I'm trying to think do I have a an example? Let's see. Okay, so if you go back to, I don't wanna say this is a common example, this just happens to be an example that we did in the last episode, where we were talking about taking two strings and sort of concatenate them concatenating them together, right. So in this case, that's sort of what the binary operator does, the binary operator functional interface takes a single type t, but it takes two parameters of that single type T and returns that same type back, which is exactly what we're doing with concatenating strings, right, we, we could have essentially leveraged the binary operator in our code, if we did already, that's great. If we didn't, we could have where we took in two strings, string one, string two, s one, S two is what we had in the previous example, both of type string and returns a string as well, right, where t equals string, right? So t is the type T equals string. In this case, in this particular example, again, that example could have been anything, right. But in this example, we did

22:23
get strings. So S one S two takes in two strings, and then it concatenates them together and returns one string, which is the two strings concatenated together with a space. Right? Okay? It could have been integers, right, you could take in two integers, in this case, t equals integer, right takes in two integers, and returns one integer. So an example of that could be more or less any, you know, simple mathematical operation, taking integer one and integer two, and then maybe sum them together, that could be the which call it, the operation that we're performing is a sum operation, right? So take in, you know, and want an end to which number one and number two, add them together and return a single integer. Okay, or it can be n one, n two and subtract them and return that single integer. That's what the binary operator does takes in two arguments of the same type and returns that same type back binary operator. So predicate by predicate unary, operator, binary operator.

23:27
What's another one? Well, to be very generic, and that almost the most generic is the function, functional interface, there's actually a functional interface called function. Right? This one's like super, super, super common, it's so common, I couldn't even think of an example to use for it, because it's just so so common. Some of the previous examples that we used could extend the function functional interface here. That's what common it is. So the function functional interface takes a parameter a single parameter of type t, and returns a result of Type R. In other words, it could be a different result, a different type, as a result, doesn't mean that it has to be different. It could even be the same, right? It could be, it could be the same if you wanted to, in which case, that would just be a unary operator, right? The unary unary operator takes one parameter of type T and returns that same type. But that could also be a function but a function where it is just

24:31
the

24:34
the type and the return type are just the same. In fact, I would, I would guess that the unary operator, let me double check this unary operator. Java is my Google I would imagine this extends function. This function whose functional method is function dot apply. Yeah, so it must extend

24:56
the function.

24:58
Yeah, super interface.

25:00
So that's what they call it. The Super interface of the unary operator is function, but it's just passing in T and T.

25:08
T as type one and t as the return type as well, but also the type. So, yeah, the unary operator just extends function.

25:17
Right?

25:19
Oh, here we go the binary operator that was talking about struggling with earlier to explain to you the super interface of binary operator is by function that makes sense. And the by predicate does that have a super interface? No, does not okay, by predicate does not have a super interface. Okay, cool. Now I'm starting to notice some stuff in the documentation. So focus, okay. function, like I said, is so generic that many things sort of extended, right function just takes any type t, any sir, I should say any argument or any parameter of type t, and returns a result that could be of a different type. Okay, that's it. And again, all of these things, all of these

26:03
functional interfaces have a single public abstract method defined inside of it. Right. So each one of these might be called something different, it can be done, you know, dot apply, the by predicate Can I see what is called the by predicate has done test, which I assume the predicate has test is its method, the binary operator has, what is the name of the single abstract method that it has inside of it.

26:32
That it's been by Max pi, I actually don't know I guess it is super interfacial. By function. So by function has apply. So by function has apply. Same with function has apply.

26:45
binary operator leverages by function, but extends it by adding in some additional helper methods that I don't want, I don't want to get distracted with those right now, I just want to talk about the basics of these guys. But just know that some of these

27:00
functional interfaces provide other sort of helper methods that allow us to do fun things with it, maybe I'll dive into one of them for the function, functional interface, since I'm supposed to be talking about the function, functional interface right now.

27:19
Java and sort of typing it in so I can get that prepped. So the function functional interface is, like I said, very generic, it can take in any type t and return any result are. So this one is used

27:35
a lot everywhere, right? Think of any function you've ever written in your life in Java that would fall under this flag that under this not flag weather, this template, okay, pretty much, almost all of your code that you've written, except for the exception of when you have two inputs into the method, or three inputs, or four inputs, right function is just for one input. And then a different result. Type I should say, by function takes into so you see how generic these are you see why these,

28:13
these interfaces were supplied to us by Java, because they're so so common, and you can use them everywhere. Okay, that's what makes this stuff so powerful. And that's what allows us to leverage the beautiful, non verbose syntax of the

28:33
lambda syntax, right? The lambda syntax is super, super easy. In terms of easy on the eyes, a lot going on under underneath the hood, which is why we're talking about it, but super easy on the eyes. Okay. So

28:46
next up is one called supplier. Okay, another functional interface. supplier is also fairly common. Supplier doesn't take any parameters at all. It just produces a result of type T. Okay, so no inputs, just produces a result. So an example of when you might use this is, if you just want to have a function that just quickly produces any result, right? So an example might be, hey, give me a random number. Like there's no the you don't need to give it an input. You don't there's no input to a function that just returns a random number. It's just hey, give me a random number. I don't need to give you anything, you just need to give me a random number. So that's, that's an example of a supplier it supplies a result without having to take anything in as an input. But the type that it returns as a result is of type T. So take that for what it's worth you need to have, you need to specify that type. Now the this one gets tricky because it can confuse people with the syntax. So I want to dive in to specifically the syntax of a supplier functional interface.

30:00
When it comes to typing out the lambda syntax, so again, lambda syntax calling back to the previous episode, lambda syntax is when you have that arrow, right, the minus sign with the greater than symbol together. That's the arrow. That means lambda in my brain, that's what I do. There is something to the left of lambda something to the right of the lamda. To the left of the lambda is the method signature to the right of the lambda is the body of the method. That's how this works. Now, what is the method signature of a method that takes no inputs?

30:34
Okay, I'll say that, again, what is the method signature of a method that takes no inputs? So the method signatures is the name of the method and then an empty, open and close bracket, or opening close parentheses, I should say. So it's the it's just the name of the method, and then boom, boom, open bracket, close bracket. But remember, in the lambda syntax, we don't need the name of the method, because you already have a method that we are using and leveraging that as a single public abstract method inside of the functional interface. Right.

31:04
So what is the syntax, the syntax is just an empty opening, close parentheses, that's it, there's no name that goes in there. It's just an empty, open, close, and then the arrow, and then there's the stuff on the right of the arrow, which you know, should return something if you don't define the body with the curly brackets, if you just want it to return, you can omit the body, if you can do it all in one line, you can omit the body and just say, you know, for this example, returning a random number, it could be just be, you know, the open close parentheses, arrow, and then math dot random, done. Right, math dot random, it'll automatically return that. And great. There's our an example of a supplier method that we have implemented with a lambda syntax. Okay, so that's the tricky, the tricky part of this supplier syntax is there's no inputs. So just have to remember that the empty brackets are needed, it needs something, even if it's empty, because hey, that exists in the real world, too. We can have methods that take no inputs, how do you properly write out the syntax of a method that takes no inputs? It's just an open and close parentheses with nothing in between. Okay, same goes for the lambda syntax. Cool. Cool. Sorry, if the clap was loud. So next up is Consumer functional interface is the last of our sort of seven that we're talking about. The Consumer functional interface.

32:28
Also pretty common.

32:30
It's kind of the the, the polar opposite of the supplier. So there's supplier and a consumer, a consumer, if you had to guess if it's what is the opposite of a supplier? If a supplier takes no inputs, and rather just returns an output of type t, a result of type T? What is the opposite of that? Well, it's the consumer, which takes a parameter of type T but doesn't return any results.

32:57
Okay. So you might be thinking, Wait, a consumer takes a parameter, a single parameter of type t, but doesn't return anything? Well, how is that useful? Have you ever written a method that takes inputs but doesn't have any outputs whatsoever? Well, possibly, what about logging, logging is a very common example of this, right? When you are logging something, you're taking some sort of input, which is typically a message or something, and you're printing it to the log, but you're not returning anything, it doesn't need to return anything, it's just a void method. Right, that's what a consumer is a consumer will take an input to consumes an input and just doesn't return anything back. Has it doesn't need to so again, a common example this might be logging something or or it's just like a system out print line type thing. Good example of leveraging consumer and whatnot. So, those are the seven common types really five are common and then there was two in there that I threw in there that were you know,

34:00
variations of the common ones the common ones are predicate which takes a parameter returns a Boolean

34:09
unary operator takes a parameter and then returns a parameter of that same type t okay. So predicate unary operator function which is super common takes any type t returns any type our supplier

34:26
takes in nothing but returns something consumer takes in something but returns nothing.

34:33
Okay. And then there are variations of them right. So predicate has by predicate unary operator has binary operator function has by function supplier might even have by supplier I don't even know if I typed in

34:45
by supplier.

34:48
Java, would that would that exist? Maybe it looks like it might by supplier.

34:55
I've seen by consumer by predicate by function but not by supplier. The concept to me

35:00
function predicate different in supplier blah, blah, blah. Anyway, it looks like there is no by supplier.

35:05
A by supplier simply wouldn't make sense a method returns a value of a single type in Java. It's true. That's good point. Yeah. Okay. So the supplier supplies a result of type t, which is the return statement. In Java, you can't return two types, so to speak. That's just not how Java works. So a by supplier wouldn't actually make sense. You can't return two different types, unless they are concatenated inside of one type, right? Then you just return the one type. So that's my bad. So yeah, there's a by predicate a binary operator a buy function, a by consumer, but not a by supplier, because that wouldn't make sense. But, you know, there you go, you learn something. I'm literally just learning something new in front of you, which makes total sense. But there you go.

35:50
And there are variations on all those as well. There are some that specifically deal with specific types and whatnot. But yeah, I don't want to get into those because you know, we could we could be here all day talking about it. But those are the important ones that you need to fundamentally understand. I mean, you don't have to fundamentally understand them. But understanding them really helps to demystify all of the stuff that we're about to talk about, which is streams in the next episode. So having this foundational knowledge really helps to clear stuff up, when we're talking about streams, just helps to live some of the fog and some of the gaps in the knowledge that might lead to confusion and head scratching. So those are the popular functional interfaces. One thing to mention, is that the function functional interface, so the function, functional interface in Java, let me just pull up the doc on that guy. Where is it? Here it is. So the function functional interface has other methods inside of it, that are that are called default methods. So one of the caveats to functional interfaces is that yes, there can be only one public abstract method inside of a functional interface. If you try to add any more than one public abstract method, it will fail, but you are allowed to have as many default methods in there as you like, because default methods you are forced to supply a body. In other words, they are not abstract. Okay, so you can add other non abstract methods inside of functional interfaces. And this is what Java does provide to us, in many of these functional interfaces that I've already talked about. So for the function functional interface, to give you an example of one of these, there's a default method called and then

37:42
I'll say that, again, there is a default method included in the function functional interface. There's a default method called and then, and that default method called and then takes another function.

37:59
Okay, so what this allows us to do is we can run or execute one functional one function, functional interface, lambda method, right, we could supply a method that does something, and then we can chain another one, we can chain another function after it with the dot, and then you can pass it another functional interface. And guess what we do that another function functional interface, that one can then be chained with dot and then

38:30
okay, so you can have this method chaining of do this, and then that, and then that, and then that, and then that and that and then stop, right. So

38:39
really super powerful stuff. And this is highly leveraged inside of streams, as we will talk about in the next lesson, such as one example of one default

38:50
method that is, you know, identifier used inside of just one of the super common functional interfaces. Just to give you an example, and just let you know, there's more to these functional interfaces than just the single public abstract method. There's also some default methods in there that are super helpful, that allow us to unlock a lot of additional functionality. So cool. Having said that, the important topic outside of this that I want to chat about, which I'm sure you see coming is the Java bootcamp. Again, we run these every single month. If you love this content, if you'd love to learn this stuff, if you're passionate about it, if all you want to do is get paid to be a coder, but you just haven't gotten there yet. You've been struggling with it, you need help. If you've been trying to do it on your own.

39:35
It's time to consider bringing on some help right. So inside of my boot camp, I forget I've talked about this I've probably talked about this before if I have forgive me, but it's important to say a lot of people think that boot camps are

39:51
only for someone who's already wealthy and they're super expensive and you know, I could never afford a boot camp. And while that is true, there's a lot of X there's a lot of support.

40:00
Along with boot camp, right? It's not just an online course. Again, I've said this in the past, if I wish I could just run my business with online courses, they are so much easier, I could do what I'm doing right now, all day long. I could talk to a microphone all day long and send it out to millions of people. I could record a video series a bunch of lectures and put them out and sell them to people all around the globe and not have to worry about it. Boot Camps are so much more work for me, I've had to hire a team, I've got a team of like five people working for me now. There's so much more of my time goes into running a boot camp than anything else I've ever had to do my entire life. I should say, in my professional career, boot camps are so exhaustedly involved, but they produce results. And that's why I'm running a boot camp again, I would much rather I actively tried not to do a boot camp. Guys, I, I didn't want to do it. But I couldn't argue with the math and the numbers. The purpose of my business is to help create the next generation of great coders. Okay, I want to I want to empower you guys to have the knowledge and the confidence and the abilities to go out there and get a job as a coder and literally change the world and change your life. I know that's a bit it sounds, you know, a bit HYPEE. But it's true. If you're someone who has an average salary and average middle class salary, becoming a coder multiplies that by like a factor of two to four, two, sometimes like 10. Yeah, it depends on where you live, it can be 10, though.

41:39
It is a very lucrative career, as I'm sure you already know. But there's a reason why it's so lucrative. There is a huge lack of coders out there a huge lack of capable coders out there. And you know why there's a huge lack of capable coders. Because it's so, so difficult to learn this stuff. Okay. So if you have been trying to learn this on your own, if you've been trying to learn it from books, from podcasts, from YouTube videos, and series, and, and some courses, some online courses that you've purchased for, you know, anywhere from $1, to like $50 to $100, and you still don't seem to be getting it and there still seems to be a lot of frustration and gaps in your knowledge and you still stare at your screen blankly when you come up to like a project that you need to do or an assignment and you're like, I don't even know where to begin. There's a reason for that. This stuff is hard. Every single bootcamp student I've ever taught goes through that.

42:37
Okay, learning how to code is extremely difficult. You wouldn't think it, you wouldn't believe it, when you hear the people out there on the street, so to speak, and on the internet, touting that they are self taught. And I you know, don't take a boot camp, they're scams and don't, don't go to college, it's a scam, that kind of thing. Well, that's a very vocal minority. In my experience, I want I don't know, it's like Survivor bias is sort of what's happening there. It's like this one guy was able to do it on their own. And this one girl was able to do it on her own, and do it self taught without having to, you know, spend a bunch of money, etc, etc. Yes, it can be done. But in my experience, that is the vast minority of people, but they tend to be the loudest, right? I think in our society today, we're very familiar with the vocal minorities. So that is, what's happening here. If, if that's what's in your head, if you believe that? Well, it's entirely possible to do it on my own. Yes, it's just highly unlikely. And if you could do it on your own great, my work here is done. I wish, I wish that 100% of the people could do it on their own. Because then I could have a great business just doing what it is, that's so much easier, which is just recording podcast episodes, YouTube videos, and online courses. And that's it. That's not the reality of the situation that we are faced with in today's world. So that's why boot camps exist. Boot Camps exist, to kick your butts to hold you accountable to give you a deadline, and to enforce that deadline and and get you past these roadblocks, that you hit these mental roadblocks that stop you from moving forward and make it so easy to quit. Right? But when you've invested in a boot camp, it's a lot less easy to quit, because you've got a lot of money on the line, so to speak. So getting back to my original point of, you know, boot camps are expensive. Yes, but that's why we have a lot of financing options available. If you live in the US right now. And you're listening to this and you have decent credit. There's tons of financing options available, so much so that you might even be able to do the Bootcamp for $0 and you don't pay until after you have graduated. Okay, maybe even three months after you graduated from the boot camp. So think about that. You can literally pay nothing now. And then you don't pay until after you graduate and once you have employment which

45:00
Most of our coders that graduate have a job within a month or two, I think 80% Get a job within the first month or two after the bootcamp. Okay, it's a six month bootcamp. So if you if you're someone that we don't see this a lot, because normally the people who are most interested in taking this career track, maybe don't have the greatest credit, because they've been working in a job that doesn't pay them, well, they haven't been able to pay all their bills, and they, there are some collections, and there are some issues with their credit. But hey, if you're someone who has decent credit, you know, decent being, you know, above 650 credit score, you could probably get approved for $0, down to go into the bootcamp. Right. So then that's not an excuse anymore, you don't have the excuse of I can't afford it. You can't afford $0. So then it's just a matter of you don't believe that it's worth it. You don't believe that this can be done?

45:48
And I would say that if you come at it with that attitude, then you're probably right. Right? The beliefs that we hold, tend to become reality with time, right? If we truly believe that we are incapable, then guess what's going to happen?

46:06
Right. But if we truly believe that we can do something, guess what's going to happen?

46:12
Right? There's a very popular quote, I forget who it was it said it. It's whether whether you believe you can or whether you believe you cannot. You're correct.

46:22
Okay, I forget, I should know who that is. I think I was like, I think Henry Ford is the one who's quoted as saying, and I forget if it's Henry Ford, but it's very true. Mindset is so important, which is one of the main aspects inside the boot camp, this reassurance that you can do it, this reassurance that I've seen it hundreds of times, if not 1000s of times before, what you're going through right now. I've seen that play out time and time again. And all it takes is to realize, Oh, I'm not alone. Okay, I'm not stupid. Oh, I'm not an idiot. Oh, this is very hard. And oh, all I need to do is just stick to it and listen to my mentor, listen to Trevor, listen to his staff, follow the curriculum, do the proven system that leads to the amazing outcome of getting a job as a coder. Right? So anyway, there's plenty of options in terms of financing. Again, if you have decent credit, and you are someone who lives in the US lots of options. If you're in Canada or the UK, we do have options for something called an income share agreement, our income share agreement, if you've heard about that before, and you have a lot of negative connotations in your mind. Our income share agreement is not a pret a predatory practice. Okay, there's a lot of predatory income share agreements out there that take a huge chunk of your paycheck, some take up like 50% of your paycheck every month to pay, but it's just ridiculous. So ours is like 9.8%. So anyway, there's an income share agreement whereby you put some money down before the bootcamp is not $0. But you do put some money down before the boot camp, usually, it's like 10 to 20% of the cost. And then that the first all the rest until after you graduated. And once you have a job, right, so there are those options to these become very affordable as well, in contrast to paying off the entire balance of the bootcamp upfront. So just to let you know, just to sort of SWAT down some of the objections that you might have in your head, it is possible, okay, it's very possible to afford it, it's very possible to get into it. It does cost money, yes. Because this is the most intensive

48:28
program that you're ever going to enroll into with respect to achieving your goal of getting a job as a coder. So if you want to get a job as a coder,

48:38
I'm obviously a big believer in boot camps in general now, because I've been doing this for 10 years, and I see that the boot camps are the most effective way, and the fastest. And believe it or not the cheapest way to get a job call back to another episode I've done on explaining the financials, of being self taught versus boot camp versus going to school, the post secondary through university or college, whatever. Boot Camps are actually the cheapest. When you look at the data and laid out in front of you, on average, boot camps are the cheapest route. So there's no excuse. The only excuse in the book, in my opinion is if you don't live inside of you know, US, Canada, UK, or some you know, quote, unquote, wealthy country, if you are in a country that is not wealthy, that is unfortunate. I don't have a financial solution for you. I'm so sorry. I wish there was a way that I can literally help every human being on planet Earth. But the the economics of it just don't work. If you don't live inside of a quote, unquote, you know, wealthy country, you know, somewhere in Europe or you know, North America,

49:43
or Australia or something like that. It just unfortunately doesn't work financially. So, for that there are online courses, and then you have to force yourself to be one of those 5% I'm so sorry. If you're outside of the wealthy countries, I just haven't found a way to solve that problem yet. Hey, good business.

50:00
unity there, if anyone's listening who wants to solve that problem, I'm all ears. I've been trying to solve that figure out a way to solve that problem for like a decade. Let me know if you have any solutions. Anyway, I'm rambling. That is the college campus boot camp, I probably should have said a long time ago where to go to get it, coders campus.com/bootcamp, you can apply to see if you meet our criteria to enroll. Because we are looking for people who have a little bit of prior experience. If you're listening to this podcast, you're probably good.

50:31
But yeah, you may need some prior coding experience, you do need some decent credit, if you're looking for financing if you don't have decent credit, but you can pay for all upfront Great, then you no problem there. If you

50:45
are not looking to get a job, then you might not qualify for financing. Because the whole usually the whole financing thing is based off of getting a job. So if you don't want to get a job as a coder, might not be a good fit. But hey, you might as well still apply to see if you get through. We have the whole point is to apply coderscampus.com/bootcamp applied to the boot camp and book call with one of our admissions advisors to have a chat and like I said, make sure that you're a good fit. That's what that call is about. We're going to talk about the boot camp, the specifics of it all the inner workings, we're going to figure out what the best way forward is for you. On this call, we're going to give you the plan the curriculum, we're going to show you the path. And if you want to take that journey with us in the boot camp, and you meet our qualifications. Great, we're happy to accept you into the boot camp and get started. Like I said, we have new ones starting every single month. If you don't meet our criteria, it might just be because you need to brush up on your fundamentals, in which case, we will send you to one of our free courses. You can do the free course once you've completed it, let us know we'll have a look at your code. And then guess what you can get entry into the next boot camp. So

51:57
sound good coderscampus.com/bootcamp. Looking forward to seeing you there. Thank you so much for listening to me talk through all this. If you're still listening, you are incredible, I love you. I can't wait to continue to bring out these episodes, and hopefully Hey, even to see you potentially in the boot camp. But just listening to this is an amazing form of support. And I'm very grateful to have your ears for this conversation right now. And I look forward to the next conversation where we will hopefully be diving into streams. I don't see why we wouldn't be diving into streams in the next episode, but you never know what the future holds. So I'm going to assume that we'll talk about streams next. And I can't wait to see you there. So take care of yourself as always happy learning. And bye for now. Thanks for listening to this episode of the coders campus podcast. But before you go, Trevor has a favorite ask you. In order to keep these episodes free, he'd love for you to leave a rating and review the podcast on iTunes. Just go to coaters campus.com/review to leave your own rating and review of the show. So if you have 30 seconds to spare right now, please help out by leaving a rating and review via coders campus.com/review It will ensure that you continue to get these awesome free podcast episodes each and every week. So if you like free swag, head on over to coders campus.com/review Happy Learning

 

Free Java Roadmap

Discover exactly what you need to learn and where to start in order to become a professional coder.