File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Variables trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Variables trouble" Watch "Variables trouble" New topic
Author

Variables trouble

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
How do I get my variable to be set to a value during runtime and then be able to be accessed by all the class methods?
I have

The problem is I set the itemSelected value but when I come to use it in the editDefectReport method its value is null. I though setting it as a global varaible allowed all classes to access the value?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

As shown, this will work as you expect; perhaps there's a bit more to the code that you're not showing us that's causing the problem.


[Jess in Action][AskingGoodQuestions]
Alex Cano
Greenhorn

Joined: Oct 06, 2003
Posts: 11
>The problem is I set the itemSelected value but when I come to use it in
>the editDefectReport method its value is null. I though setting it as a
>global varaible allowed all classes to access the value?
I agree with Ernest. The code you show here should work as you expect as long as you're setting it in the same instance of the class that you're calling the editDefectReport method on (assuming something else in your code isn't setting this value to null after you set it to whatever you initially set it to). I would post the remainder of the relavent code for this.
Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
Thanks very much, I have managed to identify the problem - I was using seperate instances - and everything is working again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Variables trouble