HTML

A Beginners Guide to Package in Java

If you are learning Java then you might have come across package concept and if you are wondering what is package and why should we use it then you have come to the right place. In this article, I will explain what is package in Java and other stuff around the package, including some best practices which using the package in Java. In the simplest form, a package is a way to organize related functionality or code in single place in Java. If you look from File System perspective then a package in Java just represent a directory where Java source file is stored in compilation and class files are stored after compilation. For example, if you create a class HelloWorld in a package called com.java67.welcome; then it will reside under directory com/java67/welcome in the source tree and you can view that in your IDE like Eclipse or Netbeans or even by navigating to file system.

How to remove duplicates from Stream in Java 8 - Stream.distinct() Example

You can use the Stream.distinct() method to remove duplicates from a Stream in Java 8 and beyond. The distinct() method behaves like distinct clause of SQL which removes duplicate rows from the result set. The distinct() is also an intermediate method which means it will return a new Stream without duplicates, which can be used for further processing. Like other methods of Stream class e.g. map() or filter(), distinct() is also lazy and it will not remove duplicate elements until you call a terminal method on Stream.  The actual processing of Stream pipeline starts only after calling terminal methods like collect() or forEach().

100+ Data Structure and Algorithm Interview Questions Answers for Programmers

Data structure and algorithms are core part of any Programming job interview. It doesn't matter whether you are a C++ developer, a Java developer or a Web developer working in JavaScript, Angular, React, or Query. As a computer science graduate, its expected from a programmer to have strong knowledge of both basic data structures e.g. array, linked list, binary tree, hash table, stack, queue and advanced data structures like the binary heap, trie, self-balanced tree, circular buffer etc. I have taken a lot of Java interviews for both junior and senior positions in the past, and I have been also involved in interviewing C++ developer. One difference which I have clearly noticed between a C++ and a Java developer is their understanding and command of Data structure and algorithms.

Java 8 Optional Example - isPresent(), OrElse() and get()

The Optional class in Java is one of many goodies we have got from the Java 8 release. If you use correctly, Optional can result in clean code and can also help you to avoid NullPointerException which has bothered Java developer from its inception. Even though many of us have used null to indicate the absence of something, the big problem is that if you call a method or access a field on the null object (except static fields), you will get a NullPointerException and your whole program may crash. The bigger problem is to find the faulty code or root cause because NullPointerException only indicates the line when you try to access field or variable from a null object but how does that null is get created on the code is unknown.

Top 15 Spring Boot Interview Questions with Answers for Java/JEE Programmers

Hello guys, if you are preparing for your next Java interview and Job description mentioned about Spring framework, then you should also prepare some Spring Boot interview questions to avoid disappointment. The Spring Boot is now the standard way to use Spring framework for Java development and almost all the companies are moving from the traditional way of using Spring Framework to more modern Spring Boot way. Gone are the days, where questions like have you used Spring Boot was asked to the developer. Nowadays interview expects more knowledge of Spring Boot from candidates and there are reasons for it, which we'll explore in this article.

Top 5 Books to Learn Grails Framework for Java and Groovy Developers.

Earlier, I have shared some of the must-read Groovy books and today, I'll share some of the best books to learn Grails for Java developers. Grails is a web application development framework completely written in Groovy. The Grails and Gradle framework are built using Groovy language. Grails is the framework to develop a web application using Groovy. The concepts within Grails, like interceptors, tag libs, and Groovy Server Pages (GSP) are very similar to what we have in Java. You'll be amazed at how quickly you can have a first-class web application up and running from ground zero. Grails includes everything you need in a single zip file on a web server (Jetty), a database (HSQLDB), Spring, Hibernate, even a Groovy version of Ant called GANT.

Java 8 - Stream.collect() Example

The collect() method of Stream class can be used to accumulate elements of any Stream into a Collection. In Java 8, you will often write code which converts a Collection e.g. List or Set to Stream and then applies some logic using functional programming methods like the filter, map, flatMap and then converts the result back to the Collection e.g. List, Set or Map. In this last part, the collect() method of Stream helps. It accepts a Collector to accumulate elements of Stream into specified Collection. The Collector class provides different methods e.g. toList(), toSet(), toMap(), and toConcurrentMap() to collect the result of Stream into List, Set, Map, and ConcurrentMap in Java.

21 Websites to Learn How to Code for Free Online

Hello there, if you are someone who is learning programming and coding by yourself and looking for some awesome resources then you have come to the right place. In this article, I am going to share 25 websites you can use to learn the code for free from the comfort of your office and home.

1. plurasight.com
One of the best website to learn any technology or IT courses e.g. programming language like Java, web development framework e.g. Spring Framework, Hibernate etc. It's also now acquired CodeSchool which earlier allows you to learn web technologies by doing it. I use this website to learn a lot of cool stuff in no time.

What is double colon (::) operator in Java 8 - Example

The double colon (::) operator is known as the method reference in Java 8. Method references are expressions which have the same treatment as a lambda expression, but instead of providing a lambda body, they refer to an existing method by name. For example, to print all elements of the list you can use the forEach() method as follows

list.stream.forEach( s-> System.out.println(s));

but here you can replace lambda expression with method reference to improve readability as shown below:

list.stream.forEach( System.out::println);

You can use method reference or double colon operator to refer a static method, an instance method, or a constructor.

5 Best Courses to Learn Spring Boot in 2018

Hello guys, if you remember, one of my goals was to learn Spring Boot in 2018 and I have started working towards it. As I have talked about my 3 point action plan to learn a new technology, the first step is to attend some online courses and start building from that. If you are not sure what is Spring Boot and why should you learn Spring Boot then let me tell you that it should be the first Java framework you should learn in 2018. The Spring Boot makes it really easy to work with Spring framework by removing all the starting hurdles with respect to setup and configuration. In one word, it makes it possible to write Spring-based Java application and run them like core Java application e.g. from the main method.

Top 35 Java String Interview Questions with Answers

The  String class and concept is a very important class in Java. There is not a single Java program out there which is not using String objects and that's why it's very important from interview point of view as well. In this article, I am going to share 35 String based questions from different Java interviews. It includes questions on java.lang.String class as well as string as data structure e.g. some coding questions something like I have shared in my earlier article about 75 Coding questions to Crack any Programming Job interviews.  You can use this list to refresh your knowledge about String in Java as well as to prepare for your next Java interview. If you have any good String questions which are not on this list, feel free to drop a note and I'll include in this list.