public class MainTest { PracticeWork1 grades; MainTest() { grades = new PracticeWork1(); init(); } public static void main(String[] args) { new MainTest(); } public void init() { testOut(); grades.adder(); testOut(); grades.adder(98); testOut(); } } example 2
public class MyWin extends JFrame { private static final long serialVersionUID = 1L; public MyWin() { Container c = getContentPane(); c.setLayout(new BorderLayout()); Panel child= new Panel(); c.add(child); setTitle("Example window"); setPreferredSize(new Dimension(640, 480)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); // отображаем окно } public static void main(String args[]) { new MyWin(); } } Is it correct to create in the main method the object of the class in which this main is located, and not to prescribe most of the logic in it?