Results 1 to 5 of 5
- 04-15-2008, 10:07 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 3
- Rep Power
- 0
Accessing boolean Values of another values in one class.
Hi All,
I have 2 classes. say Class A and Class B. My logic is coded in a method in class B. I am accessing this method of class B by creating an instance of class B in class A.
To explain better:
Class A{
ClassB b = new ClassB();
b.parse();
}
Class B{
parse(){
// some logic code.
}
At the end of processing the logic in parse() of Class B, I wish to set a boolean flag in Class B. such that after parse() returns what it has to, I will check the flag value and process some stuff in Class A. How can I design my solution? I tried using a static flg value in Class B. But this will not hold good in my case, because there are concurrent users to sign in to my application. Please guide and help.
Thanks,
Ashok.
- 04-15-2008, 10:25 AM #2
Hi Ashok,
Why do not you return boolean value from parse method directly..?
boolean parse(){
boolean flag;
// some logic code.
// set flag
return flag;
}
after calling parse method from class A get this boolean variable and do more....
If i misunderstand then correct me.
sanjeev
- 04-15-2008, 11:27 AM #3
Member
- Join Date
- Apr 2008
- Posts
- 3
- Rep Power
- 0
Accessing boolean Values of another values in one class.
Hi Sanjeev,
Actually the parse() returns a arrayList to me. I cannot use it to return boolean flag. I tried using a setter/getter to get the boolean flag value. Seems Ok. I am testing a few conditions.
Is there a better way I could handle this.
Ashok.
- 04-15-2008, 12:40 PM #4
Ok Ashok,
do one thing..
public ArrayList parse(){
boolean flag;
ArrayList templist = new ArrayList();
ArrayList dataList = new ArrayList();
///// do processing
templist.add(flag);
templist.add(datalist);
return templist;
}
When you get this arraylist Fist get(0)--> boolean flag and then get(1) your data list.
OK
If still some problem let me know..
sanjeev
- 04-15-2008, 01:04 PM #5
Member
- Join Date
- Apr 2008
- Posts
- 3
- Rep Power
- 0
Hey Sanjeev,
I think your solution is good! Thanks. I have not yet tried but I was meanwhile using this:
In ClassB, I created a private boolean variable to hold a flag value.
then using getter/setter modifying the flag and accessing it from ClassA. But I think you solution suits my design.
Thanks,
Ashok.
Similar Threads
-
Byte Values
By javaplus in forum New To JavaReplies: 1Last Post: 06-23-2008, 12:08 AM -
A utility class that parses a Comma Separated Values (CSV) file
By Java Tip in forum java.ioReplies: 0Last Post: 04-16-2008, 10:58 PM -
I want to get values from login jsp
By trill in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 08-07-2007, 07:33 AM -
Accept 2 values ....
By danny000 in forum New To JavaReplies: 1Last Post: 07-31-2007, 02:12 PM -
Passing the Values
By Lagarto in forum JDBCReplies: 1Last Post: 07-16-2007, 03:03 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks