I am having a problem with the following lines where car is a String array which has not been initialized/has no elements.
car
String
String c
This won't work. You first have to initialize the array. So far, you only have a String[] reference, pointing to null.
null
When you try to read the length member, what you actually do is null.length, which results in a NullPointerException.
null.length