Parallel streams are streams that allow operations to be executed in parallel, with the goal of making performance faster by dividing the work into smaller, concurrent tasks. Example: [crayon-63db641303105565568943/] In the above example, the sequential stream first sums up all the elements in the numbers list, whereas the parallel stream divides the work of summing up the elements into smaller tasks and executes them concurrently to make the process faster. … [Read More...] about What is parallel Stream
Main Content
Spring dependency injection with Java configuration
Here we are going to see how to configure dependency injection in spring with java . In the below example we have two classes MyClass and Myclass2 .There is a dependency of MyClass2 in Myclass . So lets understand how to inject the depended class into another using Spring.
1 2 3 4 5 6 7 |
public class MyClass { MyClass2 myClass2; MyClass(MyClass2 myClass2){ this.myClass2=myClass2; } } |
1 2 3 4 5 6 |
public class MyClass2 { MyClass2(){ System.out.println("Initializing MyClass2"); } } |
Below is the configuration […]
Callable and Future Interface
Callable and Future Interface : Callable and Future interface has been introduced in JDK 1.5 under java.util.cocurrent package. Callable interface is used to execute task and is similar to Runnable interface but can return value to caller and is able to throw checked Exception as well .Callable interface has call() method to execute task, computing […]
intern() method of String class
The intern() method in Java is a method of the String class. It returns a canonical representation of a string object. When you call the intern() method, the JVM checks the pool of strings and returns a reference to an existing string object if a matching string is found. If no match is found, the string object is added to the pool and a reference to it is returned. The primary purpose of the … [Read More...] about intern() method of String class
SOLID – Five principles of object-oriented software design
SOLID is an acronym that stands for five principles of object-oriented software design. These principles are intended to make software design more understandable, maintainable, and scalable. The SOLID principles were first introduced by Robert C. Martin in his book "Agile Software Development, Principles, Patterns, and Practices" in 2002. The SOLID principles are: By following these … [Read More...] about SOLID – Five principles of object-oriented software design
Java Coding Best Practices
Here are some best practices for coding in Java: By following these best practices, you can write high-quality code that is easy to read, understand, and maintain. It's also important to remember that best practices are not set in stone and you should always evaluate them in the context of your specific project and use the ones that are most appropriate. … [Read More...] about Java Coding Best Practices