How to check value of a variable

hi, all
I have 2 class: A and B
class A :
class A {
     static int count = 0;
     public int incre() {
          count++;
          return count;
     public int decrea() {
          count--;
          return count;
}class B:
class B {
     public void doSomething() {
          if (A.count == 0) {
               // I can get value because it have default value in class A
          } else {
               // I don't know when A.count increase or decrease by another    class
}When B start will call to use class A, after B finish, another class will call to use and can increase or decrease count.
When count is changing by another class, I (class B) want to know what is the value of count variable
Please help, thanks many

Depending on the actual requirement, this should be a
good exercise for using java.util.Observer and
Observable pair. See the API documentation for these
two. And, try describe your application requirement
in more detail.Thanks for your reply, but I can not use Observer/Observable to solve
To me attach example code, please see it again
class MainFrame:
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class MainFrame extends JFrame {
     private JButton button;
     public MainFrame(){          
          this.setTitle("Please help me");
          this.setSize(300, 200);
          button = new JButton("Open");
          button.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e) {
                    Object o = e.getSource();
                    if(o == button){                         
                         ChangeValue c = new ChangeValue();
                         c.show();
          this.getContentPane().setLayout(new FlowLayout());
          this.getContentPane().add(button);
          this.setDefaultCloseOperation(EXIT_ON_CLOSE);
          this.setVisible(true);
     public void howTo(){
          System.out.println("get abc variable from ChangeValue.java = "+ChangeValue.abc);
          if(ChangeValue.abc > 0){
               // I want to get value  of count variable here. But i can not
               // Please help
     public static void main(String [] args){
          MainFrame m = new MainFrame();
          m.show();
          m.howTo();          
}class ChangeValue:
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ChangeValue extends JFrame{
     JButton b = new JButton("Exit");
     public static int abc = 0;
     public ChangeValue(){     
          abc ++;
          this.setTitle("Child");
          this.setSize(250, 100);
          this.getContentPane().setLayout(new FlowLayout());          
          b.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e) {
                    if(e.getSource() == b){
                         setVisible(false);     
          this.getContentPane().add(new JLabel("You have just increase abc variable"));
          this.getContentPane().add(b);
          this.setVisible(true);
          System.out.println("You have just increase abc variable (from class ChangeValue) = " + abc);
}When MainFrame load, you press button "Open",
this button will call class ChangeValue and increase abc variable to 1
You press button Exit on ChangeValue and press button Open on MainFrame again, abc will increase to 2.
Please see howTo() method in MainFrame, i want to get value of abc variable (= 1, 2 ...) but I can not.
(See log for more detail)
Could you please help me to find the way to solve this problem !
thanks many

Similar Messages

  • How to change value of instance variable and local variable at run time?

    As we can change value at run time using debug mode of Eclipse. I want to do this by using a standalone prgram from where I can change the value of a variable at runtime.
    Suppose I have a class, say employee like -
    class employee {
    public String name;
    employee(String name){
    this.name = name;
    public int showSalary(){
    int salary = 10000;
    return salary;
    public String showName()
    return name;
    i want to change the value of instance variable "name" and local variable "salary" from a stand alone program?
    My standalone program will not use employee class; i mean not creating any instance or extending it. This is being used by any other calss in project.
    Can someone tell me how to change these value?
    Please help
    Regards,
    Sujeet Sharma

    This is the tutorial You should interest in. According to 'name' field of the class, it's value can be change with reflection. I'm not sure if local variable ('salary') can be changed - rather not.

  • XSL-How to get value of a variable from inside loop-- to the outside loop?

    Pls help
    hi im currently working on this xsl file..
    This works on generating a txt file,my problem right now is
    ' how can i get the value of a variable generated from the inside forloop,
    i have to get the total,sum value of this variables after performing the loop
    ***this is the for loop
    <xsl:for-each select="OutboundPayment">
    <xsl:variable name='id' select='generate-id(OutboundPayment)'/>
    <xsl:sort select="PaymentNumber/CheckNumber" data-type="text" />
    <xsl:variable name='PValue' select='format-number(100*PaymentAmount/Value,"0000000000000")'/>
    <xsl:value-of select='$id'/>
    <xsl:text>D</xsl:text>
    <xsl:value-of select='$DDate'/>
    <xsl:value-of select='$Batch'/>
    <xsl:text>3</xsl:text>
    <xsl:value-of select='format-number(PaymentNumber/PaymentReferenceNumber,"0000000000")'/>
    <xsl:value-of select='format-number(PayeeBankAccount/BankAccountNumber,"0000000000")'/>
    <xsl:value-of select='substring(Payee/Name,1,20)'/>
    <xsl:value-of select='$PValue'/>
    <xsl:variable name='Addend' select='concat($DDate,substring($DAcct,5,5),$Batch)'/>
    <xsl:variable name="LHash">
    <xsl:call-template name="GetHash">
    <xsl:with-param name="A1" select="$PValue" />
    <xsl:with-param name="A2" select="$Addend" />
    </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="concat('[',$LHash,']')" />
    <!--LHash*i have to get the total amount of this one from the outside loop /---->
    <xsl:call-template name='NewLine'/>
    </xsl:for-each>
    <!--I have to put in here the total value of that LHash/---->
    <!--This is the template on how to get the value of that variable in the inside loop/---->
    <xsl:template name="GetHash">
    <xsl:param name='A1'/>
    <xsl:param name='A2'/>
    <xsl:variable name='TwoSum' select='format-number($A1+$A2,"000000000000000")'/>
    <xsl:variable name='Weight' select='317191314191112'/>
    <xsl:call-template name="WDigit">
    <xsl:with-param name="Cnt" select="15"/>
    <xsl:with-param name="Sum" select="$TwoSum"/>
    <xsl:with-param name="Wgt" select="$Weight"/>
    <xsl:with-param name="Tot" select="0"/>
    </xsl:call-template>
    </xsl:template>
    <xsl:template name='WDigit'>
    <xsl:param name='Cnt'/>
    <xsl:param name='Sum'/>
    <xsl:param name='Wgt'/>
    <xsl:param name='Tot'/>
    <xsl:choose>
    <xsl:when test="$Cnt > 0">
    <xsl:variable name='Multip' select='substring($Wgt,$Cnt,1)'/>
    <xsl:variable name='Factor' select='substring($Sum,$Cnt,1)'/>
    <xsl:variable name='Prduct' select='$Multip$Factor'/>
    <!--xsl:value-of select="concat($Tot,'[',$Cnt,']')"/-->
    <!--xsl:value-of select="concat($Multip,'x',$Factor,'=',$Prduct)"/-->
    <!--xsl:call-template name='NewLine'/-->
    <xsl:call-template name="WDigit">
    <xsl:with-param name="Cnt" select="$Cnt - 1"/>
    <xsl:with-param name="Sum" select="$Sum"/>
    <xsl:with-param name="Wgt" select="$Wgt"/>
    <xsl:with-param name="Tot" select="$Tot+$Prduct"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:variable name="Rem" select="$Tot mod 11"/>
    <xsl:variable name="Chk" select="11 - $Rem"/>
    <xsl:value-of select="format-number(concat($Tot,$Chk),'00000')"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:template name='GetTotal'>
    </xsl:template>
    Thanks in advance for those who are willing to help.
    -Leighya

    It would have helped if you had posted your code as CODE but as it is, I could hardly read it. My guess about what you are asking is, if you want a template to return a value, just write that value to the result stream inside the template.
    If that wasn't what you were asking, then please post your code in a readable format.

  • How to populate values to the variables in standard text

    Hi friends,
    I have maintained a standard text in So10 like this invoice number&vbeln&.
    Inside a function module i want to read this text and populate the value to the variable &vbeln&.How to achive this.
    Rgds.

    Thanks Simon but i didn't understand your answer but i will tell you the problem that i want to solve with foreach or iterator
    i have a view that have employeeId and employeeName and ManagerID
    create table employeesView
            EmployeeId           Number,
            EmployeeName      varchar2(100),
            ManagerId             Number
        }i want to make a foreach or Iterator to make
    every Employees with the same manager id to be in the same <af:panelGroupLayout>
    i mean
      <af:foreach or af:Iterator >
           <af:panelGroupLayout >
                   <af:commandButton id="cb1" text="All Employees With Manager Id 1" />
           </af:panelGroupLayout >
           <af:panelGroupLayout >
                   <af:commandButton id="cb1" text="All Employees With Manager Id 2" />
           </af:panelGroupLayout >
           <af:panelGroupLayout >
                   <af:commandButton id="cb1" text="All Employees With Manager Id 3" />
           </af:panelGroupLayout >
      </af:foreach or af:Iterator >How can i do this

  • How to check value is numeric or not

    hi how to check whether a value is numeric or not.
    example.  data : x type n.
              x = 12345.
    Now how to check whether X contains numeric value or not.

    Hi,
         If your type is 'N' there is no way that 'X' can have any value apart for numberics (i.e. 0 - 9).
    You can also check that as follows.
    Data: num_list(10) type c value '0123456789',
          x type n.
    X = '12345'.
    This is more useful if your X is of type C.
    if X CO num_list.
    Its only numeric
    else.
    its contains non numeric
    endif.
    Regards,
    Sesh

  • How to Get Value from a Variable to restrict a Key Figure ?

    I am trying to make a query in Query designer, we are running BI7.
    I have a user entry veriable on the Fiscal year period, the user will need to enter a period they want the report for, i.e. 07.2008 for July 2008 report and 04.2008 for April 2008 report.
    Based on what the user entered as the starting period (in the variable entry), I have to then use that initial value and show the Year to date value (of sales etc) in the next column.
    To Clarify, if user entered 07.2008 then all the data from 01.2008 to 07.2008 needs to be in the next column.   if user entered 04.2008 then all the data from 01.2008 to 04.2008 should be in the next column.
    So to summarise according to my understanding, I want to get the value from a variable and pass it onto another variable to restrict a key firgure (sales amount)...
    Can someone please clarify what i need to do here?  
    Many thanks in advance, points will be awarded accordingly.

    hi,
    please follow the below steps:
    1. Create a new varialbe , this variable should be processed by customer exit.
    2.  In the column section, create a new column and drag the sales key figure, also drag fiscal year period and restrict with the new variable.
    3. In the cmod tcode write a customer exit code to extract the value of the user entry and assign it your variable, you can refer to the below code.
      WHEN '< New VAR name>'.
        IF I_STEP = '2'.                                 "AFTER THE POPUP
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
            WHERE VNAM = '<Fiscal Year Period VAR Name>'.
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW      = LOC_VAR_RANGE-LOW(4).
            L_S_RANGE-LOW+4(3) = '001'.
            L_S_RANGE-HIGH     = LOC_VAR_RANGE-LOW.       "LOW E.G. 2001006
            L_S_RANGE-SIGN = 'I'.
            L_S_RANGE-OPT = 'BT'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
        ENDIF.
    For ex- if the user enters 008/2008, this code will create as range assign 001/2008 - 008/2008 value to the variable.
    hope it helps,
    rgs,
    Parth.

  • How to change value of user variable with change in Page View Dropdown

    Hi All,
    I have a classic planning application, on one of my dataform i put members of Dim_A in Page view and on row view i filter members of Dim_B on the basis of User variable i.e row contains the @Childern(&My_User_Variable). I have following members in both Dimensions:
    Dim_A
    ___A_Mem1
    ___A_Mem2
    ___A_Mem3
    Dim_B
    ___B_Mem1
    ______B_Mem1_1
    ______B_Mem1_2
    ______B_Mem1_3
    ___B_Mem2
    ______B_Mem2_1
    ______B_Mem2_2
    ______B_Mem2_3
    ___B_Mem3
    ______B_Mem3_1
    ______B_Mem3_2
    ______B_Mem3_3
    Now is there any way through which the value of My_User_Variable changes automatically when user select a member of Dim_A in Page View drop down, so that when user press go button then my rows would also be re filtered according to new value of User Variable.
    Right now user first make change in User Variable then select its matching member from Dim_A and then rows are filtered, so i want my user to only make selection in Drop down and press go rest all would be done automatically.

    Hi,
    There was a little controversial post on a similar question:
    Re: Hyperion Planning Data Form
    I love controversy!
    Cheers,
    Alp

  • How to get value od one variable baesd on another variable

    Hi Gurus,
         Is this thing possible?My problem is  i have one variable on "0calmonth2" based on this variable i want to populated the values in another object (0calquarter).i.e.
    If i select " Jan or Feb or Mar" it should populate 1  in 0calquarter similarly, for other month

    Hello Deepak
    Try a function module like this:
    FUNCTION Z_YOUR_FM.
    ""Interfase local
    *"  IMPORTING
    *"     VALUE(I_AREA) TYPE  UPC_Y_AREA
    *"     VALUE(I_VARIABLE) TYPE  UPC_Y_VARIABLE
    *"     VALUE(I_CHANM) TYPE  UPC_Y_CHANM OPTIONAL
    *"     VALUE(ITO_CHANM) TYPE  UPC_YTO_CHA
    *"  EXPORTING
    *"     REFERENCE(ETO_CHARSEL) TYPE  UPC_YTO_CHARSEL
    *"  EXCEPTIONS
    *"      FAILED
    clear export table
      CLEAR eto_charsel.
      data: i TYPE i value 1,
            ls_charsel TYPE upc_ys_charsel,
            l_periv type periv value 'K1',
            l_calmonth2 type UMC_Y_ICHAVAL,
            l_buffer_call TYPE boole-boole VALUE ' ',
            l_subrc LIKE sy-subrc,
            ls_return LIKE bapiret2,
            l_type LIKE upc_var-vartype,
            lto_varsel_all TYPE upc_yto_charsel,
            lto_varsel TYPE upc_yto_charsel,
            lto_chanm TYPE upc_yto_cha,
            wa_varsel like line of lto_varsel,
            l_quarter(1),
            l_quarterc(5).
    Read value of CALMONTH2 variable
      CALL FUNCTION 'Z_VARIABLE_GET_DETAIL'
        EXPORTING
          i_area         = <YOUR PLANNING AREA>
          i_variable     = <YOUR CALMONTH2 VARIABLE>
          i_buffer       = l_buffer_call
        IMPORTING
          e_subrc        = l_subrc
          es_return      = ls_return
          e_type         = l_type
          eto_varsel_all = lto_varsel_all
          eto_varsel     = lto_varsel
          eto_chanm      = lto_chanm.
      IF l_subrc eq 0.
        loop at lto_varsel into wa_varsel.
          move wa_varsel-low to l_calmonth2.
        endloop.
      ENDIF.
    calculate quarter
      CASE l_calmonth2.
        WHEN '01' OR '02' OR '03'.
          l_quarter = '1'.
        WHEN '04' OR '05' OR '06'.
          l_quarter = '2'.
        WHEN '07' OR '08' OR '09'.
          l_quarter = '3'.
        WHEN '10' OR '11' OR '12'.
          l_quarter = '4'.
      ENDCASE.
    passing QUARTER to variable value
      CLEAR ls_charsel.
      ls_charsel-CHANM = I_CHANM.
      ls_charsel-SEQNO = i.
      ls_charsel-sign  = 'I'.
      ls_charsel-opt   = 'EQ'.
      ls_charsel-low   = l_quarter.
      INSERT ls_charsel INTO TABLE eto_charsel.
      add 1 to i.
    ENDFUNCTION.
    Hope this helps...
    regards,
    Ibrahim.

  • How to get value of process variable in another flex form

    Hi,
    currently we are using Flex 3 for form development in LiveCycle ES workspace.
    We have got an "Assign Task" service operation. This service operation has got a process variable defined for "input" and "output".
    The service will be called in a flex form. When the process is called a task will be sent to a user.
    When the user opens this task another flex form will be opened. All these steps work fine!
    How it's possible to get the value of the defined process variable from the first flex form (which starts the process)
    to the flex form which will be displayed when the user opens the task?
    Thanks very much for your help!
    Holger

    Solutions:
    -The 'proper' way for application specific stuff is to use a properties file, not env vars.
    -Use System.getenv(), only works for versions before 1.3
    -Use the java command line option '-D'
    -Use Runtime.exec(), similar to the way you suggested.
    -Use JNI.

  • How to derive value from another variable and use it to read master data?

    Hi,
    I have following case:
    First I need to read the value from Cost Center -variable (ZIPCC) and then I need to use that value to determine the home currency of that cost center from the cost center master data table (field: OBJ_CURR).
    I know to basic idea on how to do this, but don't seem to get the syntax correct. Could someone point me in the right direction?
    So the objects in play are:
    ZIPCC = Cost center selection variable (mandatory, single value)
    ZIPCUR = Cost Center Currency variable (customer exit, single value)
    0COSTCENTER
    0OBJ_CURR = Field in cost center master data
    Help will be greatly appreciated!
    -m

    Hi,
    Thank you very much for your example I can see that this logic works! However I'm experiencing trouble in selecting the 0OBJ_CURR
    This kind of declaration isn't working: "D1 Like /BIC/0OBJ_CURR."
    And the same goes for the Selection:
    "Select single OBJ_CURR into D1 from /BI0/PCOSTCENTER where COSTCENTER = i_t_var_range-low."
    This is where my syntax also went wrong.
    0OBJ_CURR is a unit, is there a special way to declare it and use it in the code?
    (and 0CURRENCY is a reference unit for 0OBJ_CURR).
    Do you have adivce on this?
    -miikka

  • How to store values in session variables for use later

    I am trying to read user input from a form, lookup some values from a database,
    store the combined data into session to retrieve later in the subsequent pages
    in a pageflow application. Could someone guide me as to how exactly to do this?
    The documentation doesn't seem to be of much help.
    Thanks,
    Krishna K

    Krishna,
         If you will be using the data within the course of the same page flow
    or nested page flows then you should store the data in the page flow
    itself. Simply declaring variables in the .jpf will do this. The page
    flow is stored in the session for you and it is deleted when the user
    exits the page flow. This is good because it keeps down session size.
         If you have data that you want to use across page flows then you will
    need to store in the session or globalApp.
         Here is a link to "Using Data Binding in Page Flows" it has an example
    of storing data into the session and it goes into the pros and cons of
    using each data binding scope.
    http://edocs.bea.com/workshop/docs81/doc/en/workshop/guide/netui/guide/conDatabindingXScript.html
    - john
    Krishna Kuchibhotla wrote:
    I am trying to read user input from a form, lookup some values from a database,
    store the combined data into session to retrieve later in the subsequent pages
    in a pageflow application. Could someone guide me as to how exactly to do this?
    The documentation doesn't seem to be of much help.
    Thanks,
    Krishna K

  • How to see values for bind variables in statspack output

    Hi all.
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
    PL/SQL Release 9.2.0.4.0 - Production
    CORE 9.2.0.3.0 Production
    TNS for Solaris: Version 9.2.0.4.0 - Production
    NLSRTL Version 9.2.0.4.0 - Production
    Running sprepsql.sql to get full sql and explain plan from hash value...
    SQL comes back with bind variables :1, :2, :3 etc.
    How can I find out what the values are for the bind variables so i can plug them in and run them in test db?
    Thanks for all your help.

    I don't have a trace file...
    I need to know what the values are and if there is anyway to see them from the output of the sprepsql...
    currently looks like:
    select
    r.status,
    NVL(r.required_date, to_date('12/31/3999', 'MM/DD/YYYY')),
    r.calc_qty,
    r.issued_qty,
    r.workorder_type,
    r.workorder_base_id,
    r.workorder_lot_id,
    r.workorder_split_id,
    r.workorder_sub_id,
    r.operation_seq_no,
    r.piece_no,
    r.warehouse_id,
    0,
    wbs_code
    from
    REQUIREMENT r
    where r.part_id = *:1*
    and r.workorder_type = 'W'
    and r.calc_qty > r.issued_qty
    and r.subord_wo_sub_id is null
    AND STATUS IN ('R', 'S','U','H','F')
    AND WAREHOUSE_ID = *:2*
    Thanks for your help.

  • How to print value of the variable in mail

    Hi,
    I am new to workflow and trying out some basis small work.
    i have created workflow for material change.
    whenever a material is changed mail is sended to user.
    it is working fine .
    but now i want that material number which is changed should come in mail.
    how can i achive this
    Thanks,
    Chintan

    Hi Soni
    You have the "Materialnumber" field in the event container. Pass this into the workflow container by defining a Workflow Container element and subsequently use this container as a variable in your email using insert fields option and you will have the Materialnumber visible in your mail sent.
    NB. This message is more or less a cut and paste from an other answer in this forum. So sometimes the fastet way to get an answer, is to search instead of posting questions. Just a kind reminder |
    Kind regards
    Mikkel

  • How to set values to bpel variables from Java

    I have a java class to create files and populate some contents into it. On success it returnes "File Created"
    I used the following code to achieve it :-
    WriteFiles objWriteFiles=new WriteFiles();
    String para=((oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:FileTestProcessRequest/client:HO_ORG_ID")).getFirstChild().getNodeValue();
    String result=objWriteFiles.writeHeaderInfo(para);
    (writeHeaderInfo is a method in my java class)
    addAuditTrailEntry(result);
    I works fine..Now I want to assign this reult value to a bpel variable .. I tried doin it like below:-
    setVariableData("outputVariable","payload","/client:FileTestProcessResponse/client:result" , result)
    but its not working...I get a fault ...
    Can anyone help me out...
    Thanks,
    Githa.R.S

    In this example :
       <!-- Invoke the EmployeeStatus Java class instead of web service -->
       <bpelx:exec name="invokeJavaExec" language="java" version="1.4">
          <![CDATA[
             EmployeeStatus e = new EmployeeStatus();
                String firstName = ((Element)getVariableData(
                                 "EmployeeTravelStatusRequest", "employee",
                                 "/employee/FirstName")).getNodeValue();
                String lastName = ((Element)getVariableData(
                                   "EmployeeTravelStatusRequest", "employee",
                                   "/employee/LastName")).getNodeValue();
                String empStatus = e.getTravelStatus(firstName, lastName);
                addAuditTrailEntry("Employee status is: " + empStatus);
                setVariableData("EmployeeTravelStatusResponse", "travelClass",
                             "/travelClass", empStatus);
          ]]>
       </bpelx:exec>they dont use namespaces in the xpath-expression, can you try that ?

  • How to change value of a variable by comparison​?

    Hi everyone,
    I have 2 (x and y)local variables that are calculated by some formula, then I want to say if x > y then x=y. I want to know how to make x=y in labview
    thanks
    Solved!
    Go to Solution.

    You seem to be using local variables as "variables", which is a bit odd for LabVIEW. Try to get away from this text programming mentality.
    Feel free to post your code.
    Anyway, here's what you could do.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    XgtYXeqY.jpg ‏3 KB

Maybe you are looking for