What is method overriding in Java – Example Tutorial

Method overriding in Java
Method overriding in Java is a concept based on polymorphism OOPS concept which allows the programmer to create two methods with the same name and method signature on the interface and its various implementation and the actual method is called at runtime depending upon the type of an object at runtime. Method overriding allows you to write flexible and extensible code in Java because you can introduce new functionality with the minimal code change. Method overriding is different than the method overloading in Java which we have discussed in the last article.

Difference between String and StringBuffer in Java

String vs StringBuffer in Java
String and StringBuffer are two classes which are most widely used in any Java program. If I say you can not write a program without using String in Java then it would not be an exaggeration. The string is everywhere, the main method accepts String argument, logs are String etc. Though many Java programmers familiar with String, not many are careful while performing operations on String, Since String is final in Java; every operation e.g. converting String into Uppercase, creating SubString,  converting String to Lowercase all result in a separate new String Object, which can take trigger frequent garbage collection and affect your application performance. here comes StringBuffer in Java which is a mutable version of String, though it's not as feature rich as String and you can not use StringBuffer in place of String but StringBuffer should be used whenever you are performing String concatenation instead of String in Java.

What is Thread and Runnable in Java - Example

What is Thread in Java?
Thread in Java is an independent path of execution that is used to run two tasks in parallel. When two threads run in parallel that is called multithreading in Java. Java is multithreaded from the start and excellent support of Thread at language level e.g. java.lang.Thread class, synchronized keyword, volatile and final keyword makes writing concurrent programs easier in Java than any other programming language e.g. C++. Being multi-threaded is also a reason for Java's popularity and being the number one programming language. On the other hand, if your program divides a task between two threads it also brings a lot of programming challenges and issues related to synchronization, deadlock, thread-safety, and race conditions.

What is class file in Java - How to create Class File

What is class file in Java
Class file in Java is compiled form of Java source file. When we compile Java program which is written in Java source file  ended with .java extension, it produces one more class files depending upon how many classes are declared and defined in that Java source file. One Java source file can only contain one public class and its name must match with name of file e.g. file can contain a public class whose name should be HelloWorld as shown below :

How to traverse iterate or loop ArrayList in Java

How to Loop ArrayList in Java
Iterating, traversing or Looping ArrayList in Java means accessing every object stored in ArrayList and performing some operations like printing them. There are many ways to iterate, traverse or Loop ArrayList in Java e.g. advanced for loop, traditional for loop with size(), By using Iterator and ListIterator along with while loop etc. All the method of Looping List in Java also applicable to ArrayList because ArrayList is an essentially List. In next section we will see a code example of Looping ArrayList in Java.

Difference between HashMap and ConcurrentHashMap in Java Collection

HashMap vs ConcurrentHashMap in Java
ConcurrentHashMap in Java is introduced as an alternative of Hashtable in Java, which is a synchronized collection class, that makes the main difference between HashMap and ConcurrentHashMap which is one is non-synchronized , non-thread safe and not for use in Concurrent multi-threaded environment while ConcurrentHashMap is a thread-safe collection and intended to be used as primary Map implementation especially for multi-threaded and Concurrent environment. Apart from thread-safety, there are some subtle differences between HashMap and ConcurrentHashMap which we will see in this article.