Text file to String in one line

In Java there are lot of ways to read the files. You can use FileReader, BufferedReader etc. But sometimes you want to read text file and store it directly to the String. For example you have String with numbers which are there to provide some data to your program. Continue reading “Text file to String in one line”

How does Thread interrupt?

Thread class in Java has method interrupt() which usually stops the Thread from doing something and inform it to do something else. Generally speaking it diverts Thread to another direction. Note here for any Thread to interrupt it must support it’s own interruption, now let’s see why. Continue reading “How does Thread interrupt?”

Pass By Value or Pass By Reference

I have seen many new comers are facing problem to understand the exact flow of these two topics. Both of them has specific meanings which are came from different programming languages. Before going in to details let’s first define what is reference in Java. Continue reading “Pass By Value or Pass By Reference”

Use of transient

The word transient means ‘lasting for very short time’ and in Java it specifically mean to survive from the persistent state. As we know if any class is flagged as Serializable which means it will inform JVM that it can write Object of this Class in some external Stream or in short Object can be converted to binay representation. Continue reading “Use of transient”

Run or Start

Threading is a way too broad and important concept in Java technology and not only java technology it’s a crucial term in computer science as well. Threading, specifically in java is used in almost every professional programming. Most of programmers might have faced following question in interview, Continue reading “Run or Start”

Pure and Impure Method

One of the most rare terms used in java to explain the function or method in the programming, even though this terms are commonly based on theory and not used in regular programming by the professionals but still it is worth to take a look at this specific terms which are ‘pure’ and ‘impure’ functions. Continue reading “Pure and Impure Method”

static hates non-static

In basic programming we have tried many times (by mistake) to access the non static method of class directly from the static method specifically from the main method and by doing that we get stuck to the following compile time error.
Continue reading “static hates non-static”