Why output is not printed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
26th Oct 2018, 6:50 PM
Rameshwar Shivshette
Rameshwar Shivshette - avatar
9 Answers
+ 4
showing error......
26th Oct 2018, 7:11 PM
Rameshwar Shivshette
Rameshwar Shivshette - avatar
+ 4
ok
26th Oct 2018, 7:22 PM
Rameshwar Shivshette
Rameshwar Shivshette - avatar
+ 4
again showing error
26th Oct 2018, 7:29 PM
Rameshwar Shivshette
Rameshwar Shivshette - avatar
+ 3
aswini this is construter why we need call that method
26th Oct 2018, 7:28 PM
Rameshwar Shivshette
Rameshwar Shivshette - avatar
+ 1
you have to call program function... call it like.... frame.program(); ...after object creation in main..
26th Oct 2018, 7:04 PM
ashwini
+ 1
Try this one in computer or laptop it works perfect.. import javax.swing.JFrame; class Demo{ JFrame f1=new JFrame(); Demo(){ f1.setSize(50,50); f1.setVisible(true); f1.setLayout(null); } } public class Program { public static void main(String[] args) { Demo d=new Demo(); } }
10th Apr 2019, 6:01 AM
Syntax_error_chaitu
Syntax_error_chaitu - avatar
0
create object of Program class as frame , call frame.Program();...this is working on laptop/pc ..... but I'll suggest you not to use the function name same as class name it is not a good programming practice..
26th Oct 2018, 7:16 PM
ashwini
0
I would use: Program frame = new Program(); frame.Program(); However you can't run GUI with Java in the sololearn sandbox. Example: https://code.sololearn.com/cPvoFJ9X27Zp/?ref=app
26th Oct 2018, 7:41 PM
Mirko Klotzsche
Mirko Klotzsche - avatar
0
look... void Program() is not a constructor..... it is a method..constructor is always without return type... it should be only.. Program()....
26th Oct 2018, 7:55 PM
ashwini