HTML

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.

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.

HelloWorld - My First jQuery Program

What is jQuery
jQuery is nothing but a JavaScript library that comes with rich functionalities. It's small and faster than many JavaScript codes written by an average web developer. By using jQuery we can write less code and do more things, it makes web developer's tasks very easy. In simple words, jQuery is a collection of several useful methods, which can be used to accomplish many common tasks in JavaScript. A couple of lines of jQuery code can do things that need too many JavaScript lines to accomplish. The true power of jQuery comes from its CSS-like selector, which allows it to select any element from DOM and modify, update or manipulate it. 

What is Volatile Variable in Java - When to use in Thread? Example

What is a Volatile variable in Java?
the volatile variable in Java is a special variable that is used to signal threads, a compiler that the value of this particular variable is going to be updated by multiple threads inside the Java application. By making a variable volatile using the volatile keyword in Java, the application programmer ensures that its value should always be read from the main memory and thread should not use the cached value of that variable from their own stack. With the introduction of the Java memory model from Java 5 onwards along with the introduction of CountDownLatch, CyclicBarrier, Semaphore, and ConcurrentHashMap, volatile variable also guarantees "happens-before" relationship, which means not only another thread has visibility of the latest value of the volatile variable but also all the variable is seen by the thread which has updated value of the volatile variable before these threads see it. What is a volatile variable and when to use it is always a popular Java threading question?

15 People Java Developers Should Follow on Twitter

If you are passionate about Java and would like to follow Java bloggers into Twitter then here is my list of 15 people you can follow on Twitter to keep yourself up-to-date and engage in Java world. These people regularly share the latest things in Java, JVM, Spring, Hibernate, and other Java technology. By following them, you will not only know about their latest work but also what's happening in Java world. You might be thinking just 15 people, well, there are many more which is not in this list but I regularly share their twitter handles via my twitter account @javinpaul and @Javarevisited. If you are following me then you will automatically get to know about them.

How to solve Arithmetic overflow error converting IDENTITY to data type tinyint, smallint or int in Microsoft SQL Server database

Last year we had a production issue where one of our backup jobs was failing while inserting Orders aggregated from other systems into our SQL Server database. The reason was dreaded "Arithmetic overflow error converting IDENTITY to data type int" because the table was using IDENTITY feature of SQL Server to generate OrderId, and Identity has breached it a maximum value, which is around 2.1 billion, precisely 2,147,483,647. The error "Arithmetic overflow error converting IDENTITY to data type int" comes when IDENTITY value is inserted into a column of data type int, but the value is out-of-range. For example, if the current value of Identity becomes more than 2,147,483,647, then you cannot store that into an int column because it's more than the maximum value of int in SQL Server.

3 ways to create random numbers in a range in Java

Many times you need to generate random numbers, particular integers in a range but unfortunately, JDK doesn't provide a simple method like nextIntegerBetween(int minInclusive, int maxExclusive), because of that many Java programmers, particularly beginners struggle to generate random numbers between a range, e.g., random integers between 1 to 6 if you are creating a game of dice, or random number between 1 to 52 if you are creating a game of playing cards, and you need to choose a random card, or most commonly random numbers between 1 to 10 and 1 to 100. Then, the question comes, how to solve this problem? How to generate random int values between a range? Well, you need to do a little bit of work.

How to Convert a List or Set of String to Comma Separated String (CSV) in Java 8

Before Java 8, it was not straightforward to convert a list of String to a comma-separated String. You have to loop through the collection or list and join them manually using String concatenation, which can take up more than 4 lines of code. Of course, you could encapsulate that into your own utility method and you should but JDK didn't provide anything useful for such a common operation. Btw, things have changed. From Java 8 onwards you can do this easily. JDK 8 has provided a utility class called StringJoiner as well as added a join() method into String class to convert a List, Set, Collection or even array of String objects to a comma separated String in Java.