getting no output | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

getting no output

why i m getting no output for thi program. https://code.sololearn.com/c52E4X6KoufZ/?ref=app

22nd Jan 2018, 3:23 PM
Anubhav Gupta
Anubhav Gupta - avatar
2 Réponses
+ 5
your run() function does return à string, but you never tell to print it. you could do : system.out.println(Program.run());
22nd Jan 2018, 4:15 PM
Vincent
Vincent - avatar
+ 2
listen .Your method is Static and if you want to access your Static method then their is a technique. which is object of class.static method here you can see in this program i have added Program new().run() (program new() is your object of class and run is your method name) so priniting these in System.out.println public class Program { public static String run(){ return "hello"; } public static void main(String[] args) { //here i have used this technique... System.out.println(new Program().run()); } }
23rd Jan 2018, 4:30 PM
Vishal
Vishal - avatar