You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by ma qiang <ma...@gmail.com> on 2008/03/13 08:13:42 UTC

why can not initialize object in Map Class's constructor?

Hi all,
    My code as below,

     public class MapTest extends MapReduceBase implements Mapper {
                private int[][] myTestArray;
                private int myTestInt;

                public MapTest()
                {
                       System.out.println("The construtor run !");
                       myTestArray=new int[10][10];
                       myTestInt=100;
                 }
.........................

  }

 when I run this program,I find the constructor run and the parameter
myTestInt is 100,but myTestArray is null and can not initialize. I've
no idea why the object will not initialize in Map's constructor ?
Thank you for your reply !

Qiang Ma

Re: why can not initialize object in Map Class's constructor?

Posted by ma qiang <ma...@gmail.com>.
I'm sorry for my mistake.   The object was initialized .






On Thu, Mar 13, 2008 at 3:13 PM, ma qiang <ma...@gmail.com> wrote:
> Hi all,
>     My code as below,
>
>      public class MapTest extends MapReduceBase implements Mapper {
>                 private int[][] myTestArray;
>                 private int myTestInt;
>
>                 public MapTest()
>                 {
>                        System.out.println("The construtor run !");
>                        myTestArray=new int[10][10];
>                        myTestInt=100;
>                  }
>  .........................
>
>   }
>
>   when I run this program,I find the constructor run and the parameter
>  myTestInt is 100,but myTestArray is null and can not initialize. I've
>  no idea why the object will not initialize in Map's constructor ?
>  Thank you for your reply !
>
>  Qiang Ma
>