Java Class/Package interaction -
I have two Kjav files that I tried to compile the DieRun.java and Die.java: by If your classes designated a package "dying" to play them, you have a few options. The quick option The correct option is: The directory structure must match the package structure. There is a bit more about current square paths, but it will bring you on your feet. You may also want to read. javac in the OS X Terminal I am doing / P>
Die package; Public category DieRun {public static zero main (string [] args) {die d6 = new die (6); }}
package die; Import java.util.Random; Die public category {Private Int party; Private int values; Private random RNG; Public die (int side) {This side = side; this.rng = new random (); This.value = this.roll (); } Public die (int side, int seeds) {this.sides = sides; this.rng = new random (seed); This.value = this.roll (); } Public Interval Roll () {this.value = this.rng.nextInt (this.sides) + 1; This return.value; } Public int getValue () {return.value; }}
javac * .java they use both compiled without any errors, but when I tried to run one of them (Eg.
java dierun ) failed with this error: The main category DieRun could not be found or loaded.
package is to remove the announcement so that they are in the default package. Normally not the best practice, but for the quick one-stop applications, it is perfectly valid.
java die .DieRun .
Comments
Post a Comment