Skip to content
Advertisement

How can I compare with ‘>’

I am working on a program using package for the FTC robotics tournament. My issue is with

import com.qualcomm.robotcore.util.ElapsedTime;

The variable runtime does not compare with an int as it is a Type ElapsedTime. I have tried just about every thing I could find and it either results in a compile or runtime error. How can I do: if (runtime > 10) {?

Advertisement

Answer

The documentation on this class shows quite a number of fields.

https://ftctechnh.github.io/ftc_app/doc/javadoc/com/qualcomm/robotcore/util/ElapsedTime.html

While the following code snippet should compile (and run), it may not be correct for what you are using it for. (For instance, do you care about nanosecond precision? Or are seconds good enough?)

    if (10 < runtime.time())
    {
        System.out.println("`runtime.time()` is greater than 10");
    }
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement