Java scanner and Method set in Array Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:16) -


import java.util.scanner; public class main {      public static void main(string[] args) {         tech[] std=new tech[5];         int i;         for(i=0;i<5;i++)         {             system.out.println("enter name of student");                 string name;                 scanner scanin = new scanner(system.in);                name = scanin.nextline();                scanin.close();              std[i].setname(name);             system.out.println(std[i].name);         }      }  } 

exception in thread "main" java.lang.nullpointerexception @ main.main(main.java:16)


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -