Skip to main content

Posts

Reduce method in Stream Java 8 (Stream.reduce())

  Stream.reduce() Before learning about the stream.reduce() , first we will learn two functional interfaces. BinaryOperator<T> Represents an operation upon two operands of the same type, producing a result of the same type as the operands. This is a specialization of BiFunction for the case where the operands and the result are all of the same type. The SAM is T apply ( T t , T t ) ; BiFunction<T, U, R> Represents a function that accepts two arguments and produces a result. The SAM is R apply ( T t , U u ) ; Now we will start the Stream.reduce() Reduction stream operations allow us to produce one single result from a sequence of elements. A reduction is a terminal operation that aggregates a stream into a type or a primitive. For example, a set of predefined reduction operations, such as average(), sum(), min(), max(), and count(), return one value by combining the elements of a stream. Stream.reduce() is a general-purpose method for generating our custom reduction ope...
Recent posts

How to install IntelliJ IDEA on Windows?

System Requirements and steps to install IntelliJ IDEA on Windows System Requirements:  Step 1: Download IntelliJ IDEA. Click here. Step 2: Run the downloaded exe file and click on next. Step 3: Check the checkboxes mentioned in the below image and click on next and then hit the install button. Step 4: Final step is to reboot your system before start using IntelliJ IDEA. Thank you, guys. Please do comment below if there is any query or feedback.

Enhancement & New API in JDK 11

 JDK 11 is the open-source reference implementation of version 11 of the Java SE Platform as specified by JSR 384 in the Java Community Process. The final release date  25 September 2018. In this post, we are going to discuss the enhancement and new API in JDK 11 in brief. Let's categories them into two parts. Enhancement and new API changes that are visible to Developers . Enhancement and new API changes that are  not visible to Developers . Now let's focus on the first part and in the later posts, we will discuss the second part.  What are the enhancements in JDK 11? JEP 323 : Local-Variable Syntax for Lambda Parameters Type inference( JEP 286 ) was introduced in JDK 10 for local variables. After JDK 10 , you don't need to explicitly state the type of a local-variable but you can use var. But this was not available for lambda's formal parameters.  Before JDK 11 From JDK 11 As you already know that the lambda's formal parameters support type inferen...

How to add an existing project to a GitHub Repository

  Add Existing project to a GitHub Repository Step 1: Login into your GitHub account and create a new repository. Step 2: Go to your project folder on your machine and open git bash. After that runs the command “ git init ”. This command initialized the empty git repository on your local machine. Step 3: Create a file “. gitignore ” using the command “ echo > .gitignore ”. Add the file extension or file name inside this file, those you don’t want to commit to your repository. Git will ignore all those files that will be present inside this file. Step 4: Add all the files to the staging area using the command “git add .” This command adds all the files to the staging area and all these files are now ready for the commit. And with the help of the command “git status” , you can check that all the files are inside the staging area. Also, you can see the file extension or the file name mentioned inside the “.gitignore”  are ignored by git. Step 5: Commit the files that are pre...