I am having trouble getting a random generator instance from being recognized as an object and it won't allow for use within another .class file. The base code for the random integer generator is this:
package RandomInstanceGenerator;
import java.util.Random;
/** Generate 10 random integers in the range 0..99. */
public final class RandomInteger {
public static final void main(String... aArgs){
log("Generating 10 random integers in range 0..99.");
//note a single Random object is reused here
Random randomGenerator = new Random();
for (int idx = 1; idx <= 10; ++idx){
int randomInt = randomGenerator.nextInt(100);
log("Generated : " + randomInt);
}
log("Done.");
}
private static void log(String aMessage){
System.out.println(aMessage);
}
}
I am trying to have the code below run what is above as a new instance. I have tried several methods that were apparent to me from other learnings, but they have failed me and so I request the knowledge of others for help in understanding. I say that in understanding that i literally copied and pasted the base code from another source that has it run as it's own little .class. Here is the code that tries to create a new instance:
package RandomInstanceGenerator;
import java.util.Random;
class Inst {
public static void main (String args[]) {
RandomInteger rig=new RandomInteger();
rig.main(args);
}
}
I am certain both need editing, hope I can fix this out so it works for me.
List of attempted changes:
1) Tried importing RandomInteger.class. The error given back says it cannot find symbol "Random Integer".
I used the code import RandomInstanceGenerator.RandomInteger;
.
2) Working on the next attempt later..