You are on page 1of 1

package narmadha.ValueRef; import narmadha.ClassDemos.

Student1; public class PassByVal { public static void main(String[] args) { int sId = 25; PassByVal val = new PassByVal(); System.out.println("sid initial:"+sId); Student1 student=new Student1(); student.setStudentId(1002); System.out.println("The sId are inside main before fn call" + st udent.studentId); val.passTheValueMethod(student); System.out.println("The sId are inside main after fn call" + stu dent.studentId); } public void passTheValueMethod(Student1 student){ student.studentId = 10; System.out.println("The sId are inside fn" + student.studentId); } }

You might also like