Jump to content

Is there a way for me to store a number as two integers? For example, I want to take a user's input and store it as both X and Y. I've tried "int X && int Y = kb.nextInt();" but that is incorrect. Been googling around for some help but couldn't come up with anything.

 

Thank you.

Link to comment
https://linustechtips.com/topic/456240-quick-question-about-java/
Share on other sites

Link to post
Share on other sites

You can do:

int x, y;x = y = kb.nextInt();

Feel free to PM for any water-cooling questions. Check out my profile for more ways to contact me.

 

Add me to your circles on Google+ here or you can follow me on twitter @deadfire19.

Link to post
Share on other sites

int Z = kb.nextInt();int X = int Z;int Y = int Z;

IDK if this works, but here you go.

 

You should ask on stackoverflow instead, by the way.

 

EDIT: && only works in comparative context, like an if statement:

if (int X && int Y == kb.nextInt()) return true;// orif (int X && int Y == kb.nextInt()) {    System.out.println(kb.nextInt());}

My rig: Intel Core i7-8700K OC 4.8 | NZXT Kraken X62 | ASUS Z370-F | 16 GB Trident Z RGB 3000 (2x8) | EVGA 1070 SC | EVGA SuperNova NEX650G1 | NZXT H700 | Samsung 250GB 850-EVO | 2x 2TB Seagate Barracuda HDDs 

Link to post
Share on other sites

 

You can do:

int x, y;x = y = kb.nextInt();

 

 

int Z = kb.nextInt();int X = int Z;int Y = int Z;

IDK if this works, but here you go.

 

You should ask on stackoverflow instead, by the way.

 

 

Thank you for that. Just what I needed!

 

I'll ask stackoverflow next time.

Link to post
Share on other sites

why do you need two variables to store the same information? 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

-_- No, you are free to ask for help here if you want.

I know, but you'd get better answers on StackOverflow since it's a community of people who like programming and whatnot. I'd always go to StackOverflow before I'd go here kek

 

EDIT:

 

StackOverflow is great, but it's perfectly fine to ask your questions here. We have plenty of people available to help you  :)

 

read above pls.

My rig: Intel Core i7-8700K OC 4.8 | NZXT Kraken X62 | ASUS Z370-F | 16 GB Trident Z RGB 3000 (2x8) | EVGA 1070 SC | EVGA SuperNova NEX650G1 | NZXT H700 | Samsung 250GB 850-EVO | 2x 2TB Seagate Barracuda HDDs 

Link to post
Share on other sites

I know, but you'd get better answers on StackOverflow since it's a community of people who like programming and whatnot. I'd always go to StackOverflow before I'd go here kek

 

And here I was thinking the people who come to the programming section of a tech forum liked programming.

1474412270.2748842

Link to post
Share on other sites

And here I was thinking the people who come to the programming section of a tech forum liked programming.

omg that's not what I'm saying don't put words in my mouth

My rig: Intel Core i7-8700K OC 4.8 | NZXT Kraken X62 | ASUS Z370-F | 16 GB Trident Z RGB 3000 (2x8) | EVGA 1070 SC | EVGA SuperNova NEX650G1 | NZXT H700 | Samsung 250GB 850-EVO | 2x 2TB Seagate Barracuda HDDs 

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

×