I am new to Java and I am struggling with understanding some basic concepts. For example, here, I am trying to write a program which will generate random strings by using the "Random" class in Java: http://docs.oracle.com/javase/6/docs/api/java/util/Random.html
I noticed that the class can generate random integers, so basically, my idea is to generate random integers and just convert them to a string, if this is possible. Here is my code so far:
package øv2;
import java.util.Random;
public class RandomStringGenerator {
private int randomNumber;
private void setRandomNumber(int randomNumber){
randomNumber = this.randomNumber;
}
private int getRandomNumber(){
return randomNumber;
}
private String generateRandomString(int randomNumber){
int randomString = randomNumber.nextInt();
}
}
What I really want to do is to take the field "randomNumber" and just turn it into a random number by using the Java class "Random", more specifically the method "nextInt()", and then turn that into a String. But I am not really understanding how to use the field "randomNumber" anywhere, do I even need getters and setters for it? Can I simply use "randomNumber" as an argument in any method?
Sorry if this is confusing, thank you so much for your time!