Java scanner and Method set in Array Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:16) -
this question has answer here:
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
Post a Comment