mongodb $exists not returning anything

My MongoCollection is:

{
    _id: ObjectId("560150b01f4da0390f10700a"),
    name: "Zouk Bar & Grill ",
    costing: {
        hallcost: 100,
        vegcost: 900,
        nonvegcost: 900
    },
    occasionwisecosting: {
        WeddingCost: 900,
        OfficePartyCost: 900,
        AnniversaryCost: 900,
        BirthdayPartyCost: 900,
        GettogetherCost: 900
    }
}

I am trying to retrieve the rows where we have GettogetherCost with the following query

db.property_master.find({'occasionwisecosting.WeddingCost' : {$exists : true }});

However I am getting an empty resultset:

> db.property_master.find({'occasionwisecosting.WeddingCost' : {$exists : true }});
>

read more

Preferring compile-time constants to enums in some specific cases

I’m reading J.Bloch’s Effective Java and come up with the following (Setcion about enums):

Far fewer enums benefit from associating multiple behaviors with a
single method. In this relatively rare case, prefer constant-specific
methods to enums that switch on their own values

To me this case of using compile-time constants is not clear. Couldn’t you provide a simple example reflecting that?

Preferring compile-time constants to enums in some specific cases

Preferring compile-time constants to enums in some specific cases

I’m reading J.Bloch’s Effective Java and come up with the following (Setcion about enums):

Far fewer enums benefit from associating multiple behaviors with a
single method. In this relatively rare case, prefer constant-specific
methods to enums that switch on their own values

To me this case of using compile-time constants is not clear. Couldn’t you provide a simple example reflecting that?

Preferring compile-time constants to enums in some specific cases

do-while with statement at the end

Can someone let me know some resource online that thefine this strange do-while behavior?

int i = 0;
do while ( ++i < 1 ) { //this compile (?!?)
      System.out.print("i is " + i);
}

do while ( ++i < 1 )  // this compile also!
      System.out.print("i is " + i);

while ( i > 1 ) {} //this doesn't compile, the comp. wants the semicolon

do while ( i > 1 ) {} //curiouser and curiouser, this does compile!!

Sorry I’m missing something from the do-while statement??

On the Oracle official link this is not mentioned at all:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html

read more

do-while with statement at the end

Can someone let me know some resource online that thefine this strange do-while behavior?

int i = 0;
do while ( ++i < 1 ) { //this compile (?!?)
      System.out.print("i is " + i);
}

do while ( ++i < 1 )  // this compile also!
      System.out.print("i is " + i);

while ( i > 1 ) {} //this doesn't compile, the comp. wants the semicolon

do while ( i > 1 ) {} //curiouser and curiouser, this does compile!!

Sorry I’m missing something from the do-while statement??

On the Oracle official link this is not mentioned at all:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html

read more