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!
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 trial
Austin Kladke4,494 Points
Java method question
I'm creating a method called randomLetter that has a return type of void and an empty parameter list. The method should:
- Declare a variable of type Random
- Generate a random number based on seed value of the number of die sides
- Set member variable representing current letter to data stored at index of random number
3 is what is messing with my brain. The first two parts are relatively straightforward... A random instance is created and then a random number is generated with the random.nextInt() method. Seed value is 6. I do have a member variable in the class called currentLetter but it's not letting me retrieve the index of the random number.
Jon KussmannCourses Plus Student 7,254 Points
It's easier to help if you post some code along with your question.
String currentLetter = letters[randomInt];
I think that's along the lines of what you're asking for.