Wrong output. showing null and null while i have given values

class-1
package STUDENT;

public class STUDENTS {

private String name;


public String getname() {
	return this.name;
}
public void setname(String name) throws Exception {
	if(name==null||name.equals("")) {
		throw new Exception("NAME CANT BE EMPTY OR NULL");
	}
}
public final int RollNo;
private static int NoFStudents=0;

public static int getNoFStudents() {
	return STUDENTS.NoFStudents;
}
public static final int MaxStudents=1000;

public STUDENTS(String name) throws Exception {
	if(STUDENTS.NoFStudents==STUDENTS.MaxStudents) {
		throw new Exception("LIMIT REACHED");
	}
	this.setname(name);
	STUDENTS.NoFStudents++;
	this.RollNo=STUDENTS.NoFStudents;
}

}

class 2-

package STUDENT;

public class STUDENT_CLIENT {

public static void main(String[] args) throws Exception {
	int i;
	STUDENTS[] Student=new STUDENTS[1000];

   for(i=0;i<Student.length;i++) {
	   Student[i]=new STUDENTS(i+"th");
	   System.out.println(STUDENTS.getNoFStudents());
	   
   }
System.out.println(Student[250].RollNo);
System.out.println(Student[250].getname());
Student[250].setname("kunal");
System.out.println(Student[250].getname());
}

}

@KUNAL.SHARMA5724510,
Corrected codes:

STUDENTS: https://ide.codingblocks.com/s/221789
STUDENT_CLIENT: https://ide.codingblocks.com/s/221790

In students class, in the setname method, you didn’t actually set the name. For that just add:

 this.name = name; 

I have also highlighted the line in the corrected code. :smile:

i wrote this.name=name, but still there is null

@KUNAL.SHARMA5724510
In students class, setname method, you’ve to write:

 this.name = name; 

I have attached the code for the same as well.
If the problem persists please attach screenshots of your output with your code as well.

how to send screenshot

public class STUDENT { private String name; public String getname() { return this.name; } public void setname(String name) throws Exception { if(name==null||name.equals("")) { throw new Exception(“NAME CANT BE EMPTY OR NULL”); } this.name=name; } public final int RollNo; private static int NoFStudents=0; public static int getNoFStudents() { return STUDENT.NoFStudents; } public static final int MaxStudents=1000; public STUDENT(String name) throws Exception { if(STUDENT.NoFStudents==STUDENT.MaxStudents) { throw new Exception(“LIMIT REACHED”); } this.setname(name); STUDENT.NoFStudents++; this.RollNo=STUDENT.NoFStudents; } }

@KUNAL.SHARMA5724510,
I have attached 2 screenshots with outputs. Kindly check your class names should match.
Please ping me if you have further doubts.

STILL THERE IS NULL SHOWING

@KUNAL.SHARMA5724510,
Please attach a screenshot of your output and code.
Press the PrtScr button to take a screenshot and do ctrl+v (paste) on the chat window.

its done ,thanks very much