So this is written in python but you can make it work for java.
Code:
def encoder_drive(self, target_position, max_speed):
target_offset = target_position - self.return_drive_encoder_position() #Figure out how far off you are
if abs(target_offset)> 1000: #If you're less than 1000 'ticks' away (maybe change to 1 inch for you) then drive forward more
self.y = target_offset * self.drive_constant.value # speed = offset * low constant (decreases speed as you approach target)
self.y = max(min(max_speed, self.y), -max_speed) #limit that speed to some speed x)
return False #you aren't at the position yet
return True # if you're within an inch, you're there
later on in the code you want to tell robotdrive to drive with the y variable. Take a look at 1418's 2015 code
here