+ 4
Why output is not printed
9 odpowiedzi
+ 4
showing error......
+ 4
ok
+ 4
again showing error
+ 3
aswini this is construter why we need call that method
+ 1
you have to call program function... call it like.... frame.program(); ...after object creation in main..
+ 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();
}
}
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..
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
0
look... void Program() is not a constructor..... it is a method..constructor is always without return type... it should be only.. Program()....