0

Can I replace a no number String for a int?

My question is, can I replace a String as an example String="house" and give it a int valor like 1? Then, it could be easier to make a switch for me with a String. Thanks! It's in Java btw

28th Sep 2020, 12:35 AM
ExodialGamer -juegos y diversión
ExodialGamer -juegos y diversión - avatar
4 odpowiedzi
+ 2
You can associate a number to a String by making an object. Use static to iterate amongst the same objects. https://code.sololearn.com/cXbyw8PvtiaC/?ref=app
28th Sep 2020, 12:52 AM
Odyel
Odyel - avatar
+ 3
You could create an array of objects? String[] house = {"Small house","big house"}; System.out.print(house[1]);
28th Sep 2020, 6:28 AM
D_Stark
D_Stark - avatar
28th Sep 2020, 9:58 AM
D_Stark
D_Stark - avatar
0
Thanks, I've not learned the arrays yet :'(
28th Sep 2020, 6:37 AM
ExodialGamer -juegos y diversión
ExodialGamer -juegos y diversión - avatar