Jump to content

So I'm guessing that you want something like this

 

Press 1 --> Assign variable x

Press 2 --> Assign variable y

Press 3 --> Assign variable z

 

If this is what you're trying to do then you could have a keylistener. Depending on how you're obtaining the input you could do it in different various ways but as long as you receive the input from the keyboard and know what key is pressed then you can use a simple switch statement to proceed with assigning the variables.

int keycodeRelease;switch (keycodeRelease) {    case 45:        // Do something when key 45 is pressed released    case 50:        // Do something else when key 50 is pressed released    break;    default:        // Do something when neither of the given keys are released    break;}
Link to comment
https://linustechtips.com/topic/224852-java-variable-help/#findComment-3082516
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×