Values not getting passed

5 pts.
Tags:
Java
JavaScript
public class regVO { String name; int year; public int getYear() { System.out.println(year); return year; } public void setYear(int year) { this.year = year; } String state; String city; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getState() { return state; } public void setState(String state) { this.state = state; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } } import java.util.Calendar; public class regservice extends regVO {regVO VO= new regVO(); public int regchk() { int age; int year = Calendar.getInstance().get(Calendar.YEAR); System.out.println(year); System.out.println("Current year is mentioned"); yearold=VO.getYear(); System.out.println(yearold); System.out.println("Birth year is mentioned"); age=year-yearold; System.out.println(age); return age; } } The value of the 'year' printed in class 'regVO' is same as the year entered.but when I call 'getYear()' from class 'regservice' it prints value 0(zero). class 'regVO' is the value objectclass and 'regservice' is the service class of Java in my program. when I call 'getyear()' function from my servlet its working. Please provide me with a solution at the earlist.

Software/Hardware used:
language java

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Hi geethu, welcome to ITKE. I'm having a hard time trying to understand your problem.  Please try to explain it more clearly.  Let us know with details how you are testing the code  (the values you are using, the functions you are calling and the results you are getting, and also let us know the results you expected).
    69,365 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following