简体   繁体   中英

How to call a different method(written in second class) run from different class(first class)?

  • First project --- in the Eclipse IDE -- Selenium Project

     public class StandLib () { public string URL = "http://www.google.com"; Standlib objAutomation = new Standardlib(); public static void main (String args[]) { objAutomation. testlaunch(URL); } }
  • Second proj --- in the Eclipse IDE -- Selenium Project

     public class BusinesLib() extends StandLib { public void testlaunch(String URL) { driver.get (URL); } }

If you want to call an instance method of the second class, you have to create an object of the second class and call the method through it. ( "Second" is the class name)

Second mySecond = new Second();
mySecond.myMethod();

If you want to call a static method of the second class, you can call it by mentioning the second class in following way

Second.myMethod();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM