Java Help

Just got a couple of questions from a complete noob at programming.

1. How do I change a 4 digit interger to a String?

2. How do I check the input to see if all of the numbers I inputted in are the exact same as the numbers in the String?


I am pretty sure there is a toString function that I used for android stuff. If you just use an if statement you should be able to just compare the inputted integer converted to string to the saved string. If all you want to do is have a user input like a pin and compare it you could just have the input be a string to begin with.


Here is what Bozho on stackoverflow said:

There are multiple ways:

  • String.valueOf(number) (my preference)
  • "" + number (I don't know how the compiler handles it, perhaps it is as efficient as the above)
  • Integer.toString(number)

Thanks mate