Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method call to another file

Tags:

java

methods

I have two files:

  • Test.java
  • Other.java

I wanted to learn how to call the file "Test.java" a method that is in another file "other.java"

Thank you!

like image 441
GDawson Avatar asked Feb 09 '12 15:02

GDawson


1 Answers

You either create an object of type Other and then call the method on that object:

//in the Test class

    Other obj = new Other();
    obj.methodFromOther();

or if the method is static just call:

//in the Test class

    Other.methodFromOther();

Maybe you should follow this tutorial to learn about the java programming language.

like image 94
user Avatar answered Sep 28 '22 08:09

user