How can i add set of information (in user defined data type) to an Array in java -



How can i add set of information (in user defined data type) to an Array in java -

i need get(key board inputs) store name,id,marks of several students , store them in array.. how can assign inputs array.. here code far.. new java. first assignment..

does info stored in student[] studentdetails array? or whats code need add together that.

class="snippet-code-js lang-js prettyprint-override">public class main { public static void main(string[] args){ student s = new student(null, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); scanner sc = new scanner(system.in); system.out.println("enter no. of student"); int x = sc.nextint(); student [] studentdetails = new student[x]; system.out.println("enter f name"); s.setfname(sc.nextline()); system.out.println("enter l name"); s.setlname(sc.nextline()); system.out.println("enter regno"); s.setstuid(sc.nextline()); system.out.println("enter project 1 marks"); s.setprojm1(sc.nextint()); system.out.println("enter ict 1 marks"); s.setictm1(sc.nextint()); system.out.println("enter active p 1 marks"); s.setactp1(sc.nextint()); system.out.println("enter codeing assignmnt marks "); s.setcodeasm(sc.nextint()); system.out.println("enter ict2 marks"); s.setictm2(sc.nextint()); system.out.println("enter act. p 2 marks"); s.setactp2(sc.nextint()); system.out.println("enter ict 3 marks"); s.setictm3(sc.nextint()); system.out.println("enter act. p 3 marks"); s.setactp3(sc.nextint());

the single student s right , need initialize i in for loop. like,

for(int = 0; < x; i++) { studentdetails[i] = new student(null, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); system.out.println("enter f name"); // s.setfname(sc.nextline()); studentdetails[i].setfname(sc.nextline()); //

and similar of other inputs.

java arrays input

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -