How to speed up Motors?

I am new to Java, and i’m wondering if there is a way to speed up the motor or decrease the speed by pressing a button?
(sorry if i’m too vague with my question)


int x = 0

if joystickButton.get()
    x+=.2
if joystickButton2.get()
   x=-.2

motor.set(x)