public class test {

      

      private String title;

      private String author;

      

      public test () {}


      public test (String title, String author) {

         

         this.title = title;

         this.author = author;

      }


      public String getTitle() {

         return title;

      }


      public void setTitle(String title) {

         this.title = title;

      }


      public String getAuthor() {

         return author;

      }


      public void setAuthor(String author) {

         this.author = author;

      }

      

      public void showInfo() {

         System.out.println(title+","+author);

      }

   

   

}




public class ca {

   static public int Count = 0;


   public static void main(String[] args) {

      test[] library = new test[5]; 

      library[Count].setTitle("tlqkf");

      System.out.println(library[0].getTitle());

   }

}

test 인스턴스 만들고 ca에서 실행하는데 오류가 뜹니다. Count를 0으로 초기화해도 뜨는데 어떻게 해야할까요?


오류 전체입니다

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "test.setTitle(String)" because "library[ca.Count]" is null at ca.main(ca.java:9)


- dc official App