This week I took a break from solving problems to study some concepts of object-oriented programming and data structures that I feel I need to address Hackerrank problems in a more efficient way and taking better advantage of the resources provided by the Java language. .
One of the new things I saw this week was another data structure called Binary Tree, I had already heard of it in the past, but now it was the first time I had to implement it to solve some kind of problem. This data structure is non-linear and is structured as follows: everything begins with the root node, which is where the binary tree begins, each node can have two child nodes, the left one that must contain a value less than its parent node and the right that must contain a value greater than the parent node.
I was also looking more deeply at what constructors are in a Java class. I learned that a constructor is a special method that is called when an object is instantiated. In other words, when you use the new keyword. The purpose of a Java constructor is to initialize the newly created object before it is used. Typically, the constructor initializes the fields of the object that need initialization.
I learned that lambda expressions are anonymous functions that are written exactly on the line of code where they are to be used. They look like this:
Benefits:
- Black Box Concept.
- Descriptive code.
- Simpler code.
- SOLID principles.