Search:

Type: Posts; User: SamJava_the_Hut

Search: Search took 0.12 seconds.

  1. Re: Trouble calling static methods from another class

    Yes! Finally my program works:


    package randomExperiments;

    import java.util.Scanner;
    /*
    Influenced from page 117 in textbook.
    */
    public class StaticMethodExample {
  2. Re: Trouble calling static methods from another class

    Interesting. Line 15 finally did what I wanted for result:


    package randomExperiments;

    import java.util.Scanner;
    import java.util.Random;
    import static...
  3. Re: Trouble calling static methods from another class

    Norm, I bit the bullet and tried what you said, but my worst fears have been realized. If you don't initialize the int variables, they generate the "The local variable result may not have been...
  4. Re: Trouble calling static methods from another class

    Okay done. randomExperiments.java now looks like this:


    package randomExperiments;

    import java.util.Scanner;
    import java.util.Random;
    import static randomExperiments.StaticMethodExample.*;
    ...
  5. Re: Trouble calling static methods from another class

    Nope. Getting rid of x and y also causes an error, "The method multiplyInts(int, int) in the type StaticMethodExample is not applicable for the arguments ()".


    What do you mean? They're already...
  6. Trouble calling static methods from another class

    I'm having problems calling my StaticMethodExample class in the main method of my Test class. I'm surprised, because both of those classes are in the same package.

    Here is the StaticMethodExample...
Results 1 to 6 of 6