Shiva, first thing first, please properly indent your code. It is very difficult to read it this way.
The output is correct as you have initialized the s static
string as null and inside the main() method you are calling substring() method which requires an instance of string object. Hence NullPointerException
HTH.