As discussed in the java essentials for Hadoop we can create we can create an array object while invoking the constuctor of a class as shown below:
I wanted to do the same through command line in eclipse:
Here i have create two classes MyDog.java and HelloWorld.java under the same package my project and i am trying to create the object and invoke the constructor of MyDog Class inside the main function of Hello World.java program as shown below:
Hello World Program:
If i try to excute the HelloWorld Program by clicking on Run Configurations in eclipse as shown below:
When i click on run its throwing me the following error:
What i fail to understand since my object dog is an array i can pass any no.of arguments through the main command line argument that is args ,so in this case i have passed two arguments to the array object it should have printed both,instead it is not able to point to the second argument and throwing null pointer exception.
I am not able to figure out what has gone wrong with my code.