Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAbdus Samad Ahmed
487 PointsConfused on what to do next??
This is what I have currently
String [] intAsString = { "This is Hard.", "This is Confusing.", "Not sure when I will understand it fully."}; Random randomGenerator = new Random(); int randomNumber = randomGenerator.nextInt(3);
get an error saying string cannot become a string or something along the lines
String [] intAsString = {
"This is Hard.",
"This is Confusing.",
"Not sure when I will understand it fully."};
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(3);
1 Answer
jacksonpranica
17,610 PointsHey Abdus,
Not sure what you're doing in your example.
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
These two codes of line seem to be right...except for the fact that you used a 3 instead of a 10 when it said it wanted a random range from 0 to 9.
However this line:
String [] intAsString = {
"This is Hard.",
"This is Confusing.",
"Not sure when I will understand it fully."};
Not sure why you are making an array? I'm just guessing it was for fun?
Regardless,
String intAsString = Integer.toString(randomNumber);
After doing the challenge this one got me through. In here we create the string variable, use the integer function to turn the integer into a string and then store it in the variable
Feel free to leave a comment if you don't understand.