Android Build a Simple Android App Basic Android Programming Using the Random Class

WHAT THE HECK

Please someone help me.

RandomTest.java
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10)
  randomNumber = intAsString.int

4 Answers

Samuel Moisan
Samuel Moisan
11,953 Points

Hi Aditya,

For your future question I suggest you to explain what you want to do with the code you provide, it will be easier for the community to help you.

I look on the challenge and it seem you need to convert randomNumber as an int, in the variable intAsString as a String. You can do this in multiple ways.

1

int number = 10;
String intAsString = number + "";

2

int number = 10;
String intAsString = Integer.toString(number);

3

int number = 10;
String intAsString = String.valueOf(number);

I hope this can help you!

ohhhhhhhhhhhh Thanks So Much!!!

but.. treehouse says it is wrong

Samuel Moisan
Samuel Moisan
11,953 Points

Hi,

This method should work fine, this is the one they teach in the tutorial.

int number = 10;
String intAsString = number + "";

Is it possible to ask tree house them self? Sorry but it still says " Bummer! There is a compiler error. Please click on preview to view your syntax errors!". I did that and it just made me confused.

Samuel Moisan
Samuel Moisan
11,953 Points

I don't know if you can contact treehouse. Post the question and your code, it will be easier to me or the community to help you.

How do I contact them?