Hey guys,

I'm trying to conver a while loop from C++ to java. And I'm having a problem with my while loop.

The original c++ code.

    // Out of cashiers?
    // Get next frontBusyCashierQ
    // Is cashier's finish time now?
    while(!service->emptyBusyCashierQ()                    
          && (service->frontBusyCashierQ(cashier),          
          cashier->getEndBusyTime() <= currentTime)) {
       ......
       ....
       ...
    }

My fail attempt.

  while(!service.emptyBusyCashierQ()
        && (service.frontBusyCashierQ(),
        cashier.getEndBusyTime() <= currentTime))
   {
       ....
       ..
       .
   }

The error is in line 3. Is the comma a problem inside the while loop?

Greatly appreciate any input in advance.

Does the code give a compiler error? Please post it.

What is the , in the middle of the boolean expression for?

Does the code give a compiler error? Please post it.

    CAS.java:248: ')' expected
                  && (service.frontBusyCashierQ()),
                                                  ^
    CAS.java:249: not a statement
                  cashier.getEndBusyIntervalTime() <= currentTime))
                                                   ^
    CAS.java:249: ';' expected
                   cashier.getEndBusyTime() <= currentTime))
                                                          ^
    3 errors

What is the , in the middle of the boolean express

In C++, it is allowed to put a comma in a while loop so you can separate statements that will be evaluated in some order. If I'm not mistaken it, is a sequence point and guarantees order of execution from left to right.

What is the purpose of the comma in a boolean expression? It does not make a valid boolean expression.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.