usage of ev3 ultrasonic sensor in lejos behavior based programming
You can use the lejos.ev3.robotics.RangeFinder abstraction class:

EV3UltrasonicSensor sensorUS;
RangeFinder sonar;

public UltrasonicSensor(Port port) {
    sensorUS = new EV3UltrasonicSensor(port);
    sonar = new RangeFinder(sensorUS);
}

@Override
public boolean takeControl() {
    return sonar.getRange() &lt; 0.3;
}


Use the float getRange()  method to retrieve the distance to the nearest object.