Results 1 to 4 of 4
Thread: accessing variables
- 04-23-2009, 03:25 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 5
- Rep Power
- 0
accessing variables
I have some code thats been driving me insane. I need to access some variables but cannot as they appear to not be in scope. Code as follows -
while (rs.next()) {
String result = rs.getString(1);
String r1 = new String (result);
if (r1.equalsIgnoreCase(search)){
String var_nonunique = new String ("true");}
}
if (var_nonunique.equals("true")){
etc.....
The issue is that I cant access the var_nonunique at the bottom as it cannot be resolved.
Any thoughts on how I can access this?
- 04-23-2009, 04:21 AM #2
Just define the variable out of the while loop....
Luck,Java Code:[COLOR="Blue"][B]String var_nonunique;[/B][/COLOR] while (rs.next()) { String result = rs.getString(1); String r1 = new String (result); if (r1.equalsIgnoreCase(search)){ [COLOR="blue"][B]var_nonunique [/B][/COLOR]= new String ("true");} } if (var_nonunique.equals("true")){
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 04-23-2009, 04:29 AM #3
Member
- Join Date
- Apr 2009
- Posts
- 5
- Rep Power
- 0
Thanks for that. I'd actually just realised i hadnt done that myself and now the code works.
- 04-23-2009, 04:36 AM #4
Similar Threads
-
accessing instance variables from static methods
By ravian in forum New To JavaReplies: 7Last Post: 03-01-2009, 10:09 PM -
Accessing USB
By FieryProphet in forum NetworkingReplies: 3Last Post: 12-13-2008, 05:29 AM -
Accessing file
By Doctor Cactus in forum New To JavaReplies: 1Last Post: 10-24-2008, 07:31 PM -
accessing cddrive
By milinkp in forum AWT / SwingReplies: 2Last Post: 02-06-2008, 08:38 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks