How to call a method in one class to another class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #16
    Originally posted by kreagan
    lol. Java.sun.com is your friend! Math is "public final class". (which is cool because I never knew they existed.)

    Math Class
    Yeah, ever tried to create a class that you cannot copy/inherit? public final classes are fun, but most people also forget to overload the copy constructor...

    There we go:
    Originally posted by JavaDocs for Math library
    By default many of the Math methods simply call the equivalent method in StrictMath for their implementation

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #17
      Instead of complicating matters even further: it was a compilation problem: the
      compiler couldn't find class 'first' (bad name by the way for a class).

      I already answered the OP in reply #10. It's another classpath issue again.

      kind regards,

      Jos

      Comment

      • praveen2gupta
        New Member
        • May 2007
        • 200

        #18
        Originally posted by benoypaul
        Code:
        /* first.java */
        package test;
        public class first
        {
         public static void display()
        {
         System.out.println(" welcome to java");
        }
        }
        
        /*second.java */
        package test;
        public class second
        {
         void check()
           {
            first.display();
          }
        }

        I have stored above code in test folder. first.java is compiled successfully. When I am compiling second.java , I got the following error message
        "cannot resolve the symbol variable first".

        How to correct this error?
        Hi
        you are trying to access the method without creating the object of the class.
        create the object of class first and then access the method associated with it.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #19
          Originally posted by praveen2gupta
          Hi
          you are trying to access the method without creating the object of the class.
          create the object of class first and then access the method associated with it.
          No that is not needed; read the thread and you'll notice that it's (just) a classpath
          issue.

          kind regards,

          Jos

          Comment

          Working...