0
    package Sound;

    import javax.swing.*;

    public class practice_1 {
        JFrame frame;
        public static void main(String[] args) 
        {
            practice_1 gogo=new practice_1();

            gogo.go();
        }
        public void go()
        {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JButton button =new JButton("click me");
            frame.getContentPane().add(button);

            frame.setSize(300,300);
            frame.setVisible(true);
        }
    }


this is error code 
Exception in thread "main" java.lang.NullPointerException
    at Sound.practice_1.go(practice_1.java:16)
    at Sound.practice_1.main(practice_1.java:12)

i can`t understand why NUllPointerException happen. what i know about NUllPointerException is that when i use nullpointer object it happen NUllPointerException. is that right?

sstan
  • 35,425
  • 6
  • 48
  • 66

0 Answers0