Results 1 to 5 of 5
  1. #1
    a_iyer20 is offline Member
    Join Date
    Apr 2008
    Posts
    3
    Rep Power
    0

    Default 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.

  2. #2
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    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


  3. #3
    a_iyer20 is offline Member
    Join Date
    Apr 2008
    Posts
    3
    Rep Power
    0

    Default 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.

  4. #4
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    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

  5. #5
    a_iyer20 is offline Member
    Join Date
    Apr 2008
    Posts
    3
    Rep Power
    0

    Default

    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

  1. Byte Values
    By javaplus in forum New To Java
    Replies: 1
    Last Post: 06-23-2008, 12:08 AM
  2. Replies: 0
    Last Post: 04-16-2008, 10:58 PM
  3. I want to get values from login jsp
    By trill in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:33 AM
  4. Accept 2 values ....
    By danny000 in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 02:12 PM
  5. Passing the Values
    By Lagarto in forum JDBC
    Replies: 1
    Last Post: 07-16-2007, 03:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •