The Artima Developer Community
Sponsored Link

Java Answers Forum
Problem with Sending and getting to a class

2 replies on 1 page. Most recent reply: Nov 21, 2002 6:59 AM by Anil Philip

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Trevor

Posts: 3
Nickname: paintcheck
Registered: Nov, 2002

Problem with Sending and getting to a class Posted: Nov 20, 2002 4:17 PM
Reply to this message Reply
Advertisement
Here is the block of Code I'm having problems with.

//Get Birth Year
String byear = JOptionPane.showInputDialog(null, "Enter Year of Birth:");
//Validate B Year
while(!(emp.isNumeric(byear, 1930, 1984) && byear.length() == 4 )){
if (emp.isNumeric(byear, 1930, 1984) && byear.length() == 4) {
byearValue = Integer.parseInt(byear);

}
else { JOptionPane.showMessageDialog(null, "Invalid Year Value");
byear = JOptionPane.showInputDialog(null, "Enter Year of Birth");
}

}
aEmp.setBYear(byearValue);


Trevor

Posts: 3
Nickname: paintcheck
Registered: Nov, 2002

Re: Problem with Sending and getting to a class Posted: Nov 20, 2002 4:20 PM
Reply to this message Reply
OPps hit post by accident.

here is the block of code

//Get Birth Year
String byear = JOptionPane.showInputDialog(null, "Enter Year of Birth:");
//Validate B Year
while(!(emp.isNumeric(byear, 1930, 1984) && byear.length() == 4 )){
if (emp.isNumeric(byear, 1930, 1984) && byear.length() == 4) {
byearValue = Integer.parseInt(byear);

}
else { JOptionPane.showMessageDialog(null, "Invalid Year Value");
byear = JOptionPane.showInputDialog(null, "Enter Year of Birth");
}

}
aEmp.setBYear(byearValue);


I believe the problem is that byearValue is being destroyed before I set it in another class... I tried moving aEmp.setBYear(byearValue); into the if statement but still had same problem when I do call getBYear from the other class, I get "0" eekk, Well I don't know all that much about java but hope you can help

Anil Philip

Posts: 19
Nickname: anilphilip
Registered: Nov, 2002

Re: Problem with Sending and getting to a class Posted: Nov 21, 2002 6:59 AM
Reply to this message Reply
where is byearValue declared?
I hope it is not shadowed by another variable with the same name?

> OPps hit post by accident.
>
> here is the block of code
>
> //Get Birth Year
> String byear = JOptionPane.showInputDialog(null,
> g(null, "Enter Year of Birth:");
> //Validate B Year
> while(!(emp.isNumeric(byear, 1930, 1984) &&
> 984) && byear.length() == 4 )){
> if (emp.isNumeric(byear, 1930, 1984) &&
> 0, 1984) && byear.length() == 4) {
> byearValue = Integer.parseInt(byear);
>
> }
> else { JOptionPane.showMessageDialog(null,
> ialog(null, "Invalid Year Value");
> byear = JOptionPane.showInputDialog(null, "Enter Year
> ar of Birth");
> }
>
> }
> aEmp.setBYear(byearValue);
>
>
> I believe the problem is that byearValue is being
> destroyed before I set it in another class... I tried
> moving aEmp.setBYear(byearValue); into the if statement
> but still had same problem when I do call getBYear from
> the other class, I get "0" eekk, Well I don't know all
> that much about java but hope you can help

Flat View: This topic has 2 replies on 1 page
Topic: Plz Help me ! everybody Previous Topic   Next Topic Topic: Let's try again...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use