Skip to main content

Ravi Narayan

About Me
I like solving problems and programming is the best way of doing it. I am a software engineer by profession and I have around 7 years of experience in java programming design and development.
I also like to work on web UI components and JS based desktop apps.

Popular posts from this blog

String - A story of very special class in java

String is most used java class in any java project. Java treated String as special class. Lets see, what so special in String. String Basics String is group of characters. char[] chrs = {'i',' ','a','m',' ','h','e','r','o','.'}; String str = new String(chrs); System.out.println(str); /* Output: i am hero. */ String is an immutable class. Immutable class:  A java class which object can not be modified if once created. Because String class is immutable, String is final in nature, its mean you can not modify string object once you created. Default value of string is null. Simplest way to initialize String is //object created in String Literal Pool String str = "hello world"; Above example known as String literal, All string literals in Java programs, such as "hello world", are object of String class. Another way to create String object is //object created in Heap m...

Java Thread - Let's move to parallel execution.

Assume we have 5 array of integer type and we want to add all numbers of array. 1st way ( Sequential Way ) We can pick array one by one and add all numbers and give the result. In this way only one thread (main thread) will execute the program. 2nd way ( Multithreaded Way ) In Multithreaded way, we can create 5 thread and assign an array to each thread to add all the numbers of array. All 5 thread will run parallel and give result 5 times faster than 1st way. What is Thread & Multithreading? A process may contain sub processes which execute parallel and use same resource of main process these sub processes are threads and whole phenomena called Multithreading . How to implement thread in Java? Java thread is sub process of process. In java, Thread class use to achieve multithreading in program. Initialize Thread There is two way to initialize and run thread in java. By extending Thread class By implementing Runnable interface By extending Thre...

What Is Exception in java?

Exceptions are exceptional conditions in program flow. What is the exceptional conditions? You going to read a file. Exceptional condition: File is not found.(FileNotFound Exception) You creating a new file. Exceptional condition: No space in memory for new file, you dont have rights to create a new file in drive. You are performing some operation on object. Exceptional condition: object is null.(NullPointer Exception) Mathematical exceptions like number divide by zero.(ArithmeticException) Array related exception like accessing an index which not in array(ArrayOutOfBound Exception). There are many cases where exception can occurs in your program. For your program runs as you expected,You need to perform exception handling for exceptional conditions but before go to exception handling lets know about Exception in java. public class Test{ void printName(){ System.out.println("Test"); } public static void main(String[] args) { Test test ...