needhelpquick Posted June 25, 2016 Posted June 25, 2016 Title please having trouble accessing the methods!
transmission Posted June 25, 2016 Posted June 25, 2016 you need to reference the method from the other class
Qubit Posted June 25, 2016 Posted June 25, 2016 (edited) You either have to make that object from that class and call it, e.g //Other file: Class Thing { String name; public String getName(){ ... } } // Main Class main{ public static void main(){ Thing thing = new Thing(); System.out.println(" My name is " + thing.getName() } } Or make the method static, e.g When you have a static method it is saying that you do not need to create an instance of this object to use the method. Thus static methods cannot use fields from it's the class, so they usually take input. //Other file: public Thing{ public static String getName(){ return "John"; } } // Main public static void main(){ String name = Thing.getName(); System.out.println("My name is" + name); } Edited June 25, 2016 by Qubit
anderiel Posted June 25, 2016 Posted June 25, 2016 Wrong forum, and also maybe use google first mate.
needhelpquick Posted June 26, 2016 Author Posted June 26, 2016 thx guys, even tho with osbot this wont work for what i needed :P