needhelpquick Posted June 25, 2016 Share Posted June 25, 2016 Title please having trouble accessing the methods! Quote Link to comment Share on other sites More sharing options...
transmission Posted June 25, 2016 Share Posted June 25, 2016 you need to reference the method from the other class Quote Link to comment Share on other sites More sharing options...
Qubit Posted June 25, 2016 Share 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 Quote Link to comment Share on other sites More sharing options...
The Brogrammer Posted June 25, 2016 Share Posted June 25, 2016 dis is like java 101 dood Quote Link to comment Share on other sites More sharing options...
anderiel Posted June 25, 2016 Share Posted June 25, 2016 Wrong forum, and also maybe use google first mate. Quote Link to comment Share on other sites More sharing options...
needhelpquick Posted June 26, 2016 Author Share Posted June 26, 2016 thx guys, even tho with osbot this wont work for what i needed :P Quote Link to comment Share on other sites More sharing options...
Explv Posted June 27, 2016 Share Posted June 27, 2016 http://www.tutorialspoint.com/java/ Quote Link to comment Share on other sites More sharing options...