500 POINTS, URGENT, PLZ HELP!!... PROBLEM WITH VARIABLES, TRY CATCH BLOCKS...

try
{
check = false;
            }
catch (the exception)
{
}
try
{
      if (check ==true)
      {

>> I get an error saying that check variable is not found. I am certain its because its in different try catch blocks. Is there anyway that i can pass the variable to the next try catch block.

>>Or if there is any other way around this. The Try Catch blocks are both different, one being

-->>MessagingException


-->>SQLException
deepanpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Define 'check' before first block
0
deepanpAuthor Commented:
-->Define 'check' before first block

--

Hi,

you mean Boolean check = false;

>>?
0
CEHJCommented:
boolean check = false;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

objectsCommented:
try the following:

boolean check = false;   // declare variable *outside* try/catch blocks
try
{
   check = false;
}
catch (the exception)
{
}
try
{
      if (check ==true)
      {
0
deepanpAuthor Commented:
hey objects,

i'm sorry, i should have also mentioned that the boolean check = false; --> is in the catch block of the first try catch blocks.
0
objectsCommented:
> i'm sorry, i should have also mentioned that the boolean check = false; --> is in the catch block of the first try catch blocks.

yes, I'm saying you need to move it *outside* so its visibale in both blocks
See the code I posted above
0
objectsCommented:
variables declared inside a try/catch block are only visible (scope) withing that try/catch block
0
deepanpAuthor Commented:
-->>yes, I'm saying you need to move it *outside* so its visibale in both blocks
See the code I posted above

-->>i understand that, however, if a catch is caught, i need the boolean to be false, otherwise true. so to my knowledge, i believe this will not work if i have it outside of the catch, as the var will always be false.
0
deepanpAuthor Commented:
-->>variables declared inside a try/catch block are only visible (scope) withing that try/catch block

->Is there any way where i can catch both of teh exceptions then, essentially joining the try, catch blocks. Or any way to define the variable to be called from outside, idea if possible like making it Perminent throughout...
0
objectsCommented:
boolean check = true;   // declare variable *outside* try/catch blocks
try
{
}
catch (the exception)
{
   check = false;
}
try
{
      if (check ==true)
      {
0
deepanpAuthor Commented:
-->>HAHA,

-->>:P.....

-->>I started to think.. and logically thought of a for loop outside of all of this try catch blocks, then implemented the

-->>break statement when a catch was caused... making the loop break... the loop is only in one iteration...


:P


-->>Practical Method, i'd say hey?

-->>Thanks Guys...
-->>I'll get the points refunded.

0
objectsCommented:
what i suggested above will work and avoids need for using break :)
0
deepanpAuthor Commented:
-->>The break, i'd say is a much easier method, Don't ask why.

-->>However you have figured the solution.

-->>Therefore points awarded to you.

-->>Thanks Objects and CEHJ...For all the Help...:-D...
0
CEHJCommented:
Move the statement to where i mentioned. You can do what you like with it then
0
CEHJCommented:
deepanp - can you explain why you accepted a comment that repeats the answer i'd already given?
0
deepanpAuthor Commented:
-->>CEHJ - I'm sorry, as reading above, I noticed I missed a message from you.

-->>If its possible, I will contact admin, and askthem to split points instead..

-->>However, If this is possible.

-->>If not then I do apologise.

-->>I might well be posting another problem soon - :)
0
CEHJCommented:
It is possible. I'll alert them for you
0
deepanpAuthor Commented:
-->>Please send me the link, if you are posting the message...

-->>Or do you want me to. If so, where isit again to post the issues...?
0
objectsCommented:
What CEHJ suggested would not work. You were setting the flag in the wrong place.
What I suggested was not the same as what CEHJ stated, a split is not necessary.

Try his suggestion if you like, check will never get set :)
0
CEHJCommented:
:-)

Let me know if you can see the difference between the accepted and assisted - i can't ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.