2007/11/15, Nathan Beyer <[EMAIL PROTECTED]>:
> Do you mean this?
>
> class MyObject {
> String field;
> MyObject(){
> super();
> }
> }
or simply "class MyObject { String field; }" - just as you wanted, no
any constructor ;)
>
> MyObject mo = new MyObject();
>
> With regard to fields being in their default state, that's what
> happens by default. The only thing that changes this is if you inline
> field assigment with the declaration or assign the fields in the
> constructor.
>
> As for creating a new instance without calling a constructor, that's
> what happens when an instance of something is de-serialized. No
> constructor is called; just the readObject() and related methods are
> invoked.
>
> -Nathan
>
> On Nov 14, 2007 11:58 PM, Andrew Zhang <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Is it possible to new an object without invoking any constructor? I know the
> > question is a bit weird. What I want is to create an object with all
> > null/default value for its fields.
> > Reseting all fields to null by reflection is a possible solution, but is
> > there any existing special method (no matter it's low level or Harmony
> > specific) which can achieve this goal?
> > Thanks!
> >
> >
> > --
> > Best regards,
> > Andrew Zhang
> >
> > http://zhanghuangzhu.blogspot.com/
> >
>