OOPS Concept Tutorial in Java - Object Oriented Programming

I have written several OOP (Object Oriented Programming) concepts tutorials in past and I was thinking to bring them together so that anyone who wants to learn OOP basics can benefit from them easily. In this article, I will share you my collection of OOP tutorials and OOP concepts interview questions, which will not only help you to understand four pillars of Object Oriented programming e.g. Abstraction, Encapsulation, Inheritance, and Polymorphism but also powerful design techniques of Aggregation, Association and Composition, along with SOLID design principles, which are key to write flexible, extensible and object-oriented software. Java is also a great language to start with object oriented programming, though it's not a pure object oriented language but it is the best one we have got so far. You cannot write code outside Class, which standardize the code organization.

Java 8 Comparator Example Using Lambda Expressions

In short, You can implement Comparator using lambda expression because it is a SAM type interface. It just got one abstract method compare() which means you can pass lambda expression where a Comparator is expected. Many Java programmer often ask me, what is the best way to learn lambda expression of Java 8? Of course by using it on your day to day programming task. Since implementing equals(), hashcode(), compareTo(), and compare() methods are some of the most common tasks of a Java developer, it makes sense to learn how to use the lambda expression to implement Comparable and custom Comparator in Java. One question comes to mind, can we use lambda expression with Comparator? because it's an old interface and may not implement functional interface annotated with @FunctionalInterface annotation?

How to split String by comma in Java - Example Tutorial

In the earlier article, I have shown you how to split String by regular expression and now, you will learn how to split String by comma. Since CSV is a popular format of exporting data, you often need to split a comma separated String to create an array of individual Strings. Similar to the earlier example, you can use the split() method to accomplish this task. Just pass a "," instead of "\\s+" the regular expression to remove whitespaces, as the regular expression. The split method will return an array of String, which you can further convert to a list of String. If your String contains a leading or trailing white space, make sure you trim the String before calling the split() method. Also, remember that this method will throw PatternSyntaxException if the regular expression's syntax is invalid. Lat but not the least this version of the split method is only available from Java 1.4 onwards.