Global Varibales

I am currently reading an article which states that "you cannot have global variables in java". Surely the variable named "globalVaribale" is global??
class Example{
   private int globalVariable;
   public void method(){ 
}Calypso

calypso wrote:
I am currently reading an article which states that "you cannot have global variables in java". Surely the variable named "globalVaribale" is global??You can call it global if you want, or you could call it an ostrich, or purple. None of those is the correct term.
In some programming languages, such as C, there are two kinds of variable scope--local, which means the variable is only defined and accessible during execution of the function where it's declared, and global, which means the variable is defined as long as the program is running and accessible from anywhere.
In java, the concept of "local", meaning defined and accessible only during the execution of the method, does exist. But the corresponding "global" does not. The closest thing is member variables, but they do not map exactly to the traditional definition of "global" and they are two different kinds--instance (non-static) and class (static), each with it's own rules for scope, accessibility, and lifetime.

Similar Messages

  • Functional Global Varibale is reentrant or not

    Please guide me, Functional global varible is reentrant or not.

    Just to muddy up the conversation...It depends!
    There are situations where you want to have a FGV be reentrant (preallocate clones).  Look at the Mean Pt-By-Pt VI.  It is a FGV that is set to reentrant.  This is done so that you can have multiple loops/signals performing means with the same VI and they keep their own data.
    But for the most part, FGVs should be set to nonreentrant for the sake of sharing data amonst you different loops and protecting the data.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How can I run two different vi's in same project which are accessing same global variable with out effecting the speed of the execution of both the vi's

    Hi
    I have build an Labview project with FPGA target .  I have configured an FPGA VI and an host Vi to acquire data and logged the data to a file and stored the latest data in a global variable simultanously. I have configured one more VI in the same project  to access the global variable.  I have build a dll to access both the VI as functions in LabWindows/CVI code.  My task in CVI is to update configured GUI with latest data periodically and run the  host VI continously for a long time and log the data to a file. GUI should update for every one second with latest data for this I am using the second VI in which I am accessing the global varibale in which the latest data has been stored in host VI.

    Duplicate Post (go here)

  • How can i decide the depth of all3 DMA fifo's are used as target to host at RT contoller side(host)?

    Hello,
          I am using all DMA fifos,I want to acquire data from 3 AI modules upto 50 khz frequency.Sampling rate can be varied according to application.
       please suggest me how should i allocate memory of my RT controller for those DMA fifos?I am also facing one problem, I am using 3 time deterministic loop with different different priorities,each time loop has one fifo where data is reading with polling method(first fifo.read=0 then againg fifo.read=remaining elements).and each time loop has been interact to host vi with global varibales.those global variables data update from normal time loop.can anybody suggest that this procedure is right or not.if my problem is not much clear i will again explaing my query with snapshot of my application.
    Pratima
    *****************Certified LabView Associate Developer****************************

    You wouldnt need to allocate memory separately on your RT Controller for the FIFOs. You need to create a FIFO under your FPGA target and use the FPGA interface VIs in your RT VI to access the DMA FIFO. You would need to use the FPGA interface invoke method VI to access your DMA FIFO.
    As for the other questions, I would recommend you to create a separate post the RT section of LabVIEW so that you can get a faster response to your questions.
    I hope this helps!
    Mehak D.

  • How to use parameters in oracle SQL script????

    Right now I am writing a SQL script to create a schema and build the objects of this schema....
    I use a .net winform program to run sqlplus to parse this sql script ...
    The problem is that the schema name and the tablespace's location and the sys password must be input by the user, so my SQL script should use these runtime input parameters instead of const parameters....
    So, how to use parameter in SQL script ...........
    Are there some example scripts in oracle home directory for me to refer to????

    Hi,
    UNISTD wrote:
    thanks .....
    what's the difference between variable , define, accept in sqlplus ???VARIABLE declares (but does not assign a value to) a bind variable. Unlike substitution variables, bind variables are passed to the back end to be compiled, and they can only be values in certain data types. You can not use a bind vaiable in place of an identifier, so to do something like
    CREATE USER  &1 ...a bind variable won't work.
    "DEFINE x = y" sets the substitution variable &x to have the value y. There is no user interaction (unless x or y happen to contain undefined substtiution variables).
    "DEFINE x" shiows the value of the substitution variable &x, or, if it is undefined, raises a SQL*Plus error. I use this feature below.
    ACCEPT sets a substitution variable with user interaction.
    And if the user miss some parameters in “sqlplus /nolog ssss.sql par1 par2 par5 par6”, how to use default value of the miss parameters??Don't you need a @ befiore the script name, e.g.
    sqlplus /nolog @ssss.sql par1 par2 par5 par6Sorry, I don't know of any good way to use default values.
    The foloowing works, but, as you can see, it's ugly.
    "DEFINE 1" display a message like
    DEFINE 1            = "par1" (CHAR)if &1 is defined; otherwise,it will display a SQL*Plus error message like
    SP2-035: symbol 1 is UNDEFINEDNotice that the former contains an '=' sign, but the latter does not.
    The best way I know to use default values is to run the DEFINE command, save the output to a filee, read the file, and see if it's an error message or not.
    So you can use a script like this:
    --     This is  DEFINE_DEFAULT.SQL
    SPOOL     got_define_txt.sql
    DEFINE     &dd_old
    SPOOL     OFF
    COLUMN     dd_new_col     NEW_VALUE     &dd_new
    WITH     got_define_txt     AS
         SELECT  q'[
              @got_define_txt
    ]'               AS define_txt
         FROM    dual
    SELECT     CASE
             WHEN  define_txt LIKE '%=%'
             THEN  REGEXP_REPLACE ( define_txt
                               , '.+"
    ([^"]*)
                         , '\1'
             ELSE  '&dd_default'
         END        AS dd_new_col
    FROM     got_define_txt
    {code}
    and start your real script, ssss.sql, something like this:
    {code}
    DEFINE          dd_new     = sv1
    DEFINE          dd_old     = 1
    DEFINE          dd_default     = FOO
    @DEFINE_DEFAULT
    DEFINE          dd_new     = sv2
    DEFINE          dd_old     = 2
    DEFINE          dd_default     = "Testing spaces in value"
    @DEFINE_DEFAULT
    {code}
    when this finishes running, the substitution variable &sv1 will either have the value you passed in &1 or, if you didn't pass anything, the default value you specified, that is FOO.
    Likewise, &sw2 will have the value you passed, or, if you didn't pass anything, the 23-character string 'Testing spaces in value'.
    Here's how it works:
    Define_default.sql puts the output of the "DEFINE x" command into a column, define_txt, in a query.  That query displays either the existing value of the substitution variable indicated by &dd_old or, if it is undefined, the default value you want to use, which is stored in the substitution variable &dd_default.  The substitution variable named in &dd_new is always set to something, but that something may be its existing value.
    Notice that the paramerters to define_default.sql must be passed as global varibales.
    Why didn't I just use arguments, so that we could simply say:
    {code}
    @DEFINE_DEFAULT  sv1  1  FOO
    {code}
    ?  Because that would set the substitution variables &1, &2 and &3, which are miost likely the very ones in which you're interested.
    I repeat: there must be a better way, but I'm sorry, I don't know what it is.
    I usually don't do the method above.  Instead, I always pass the required number of parameters, but I pass dummy or plce-holder values.
    For example, if I wanted to call ssss.sql, but use defulat vlaues for &1 and &3, then I would say something like:
    {code}
    @ssss  ?  par2  ?
    {code}
    and, inside ssss.sql, test to see if the values are the place holder '?', and, if so, replace them with some real default value.  The use has  to remember what the special place holder-value is, but does not need to know anything more, and only ssss.sql itself needs to change if the default values change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Error in smartform driver program.

    Hi,
        I want to know the functionality of  form interface and Global definitions.when i am executing driver program i got following error.
    Field "INTO" is unknown. It is neither in one of the specified tables
    nor defined by a "DATA" statement.
    could anyone give the solution for this error ?

    Hi Raja,
            The form interface will contain what all things U export from Driver program. ie Tables , Workarea etc.
            The Global defenitions will contain what all global varibales that U use inside SMARTFORM.
               Suppose U are exporting a work area from Driver program which is of structure Z_TEST then declare that work area in FORM INTERFACE as
    w_test type z_test.
             U have a table that U pass from Driver program into smartform let it be t_final of structure z_final then declare that table in TABLES tab of form interface as t_final LIKE Z_final.
           Declare all the varibles that U use in Global defenitions w_str type string etc.
    U might have used "INTO" as some variables or declaration might be wrong.
    Please see the declaration in Global definitions and Interface.
    Click on that Error and see where its coming.
    Reward points if Useful
    Regards
    Avi...

  • Using external files in flash

    Helo all and thank you very much for your attention ,realy I
    tried to use two external text file (bill.txt and les.txt) .when I
    click on bill button ,the flash file load bill.txt and when I click
    on les button the flash file load les.txt .for this case I use two
    sepaate action script for each of the buttons:
    action script for bill button:
    on (release) {
    willieLoad = new LoadVars();
    willieLoad.onLoad = function() {
    _root.twoNuts.text = this.bill;
    willieLoad.load("bill.txt");
    action script for les button:
    on (release) {
    leslieLoad = new LoadVars();
    leslieLoad.onLoad = function() {
    _root.twoNuts.text = this.les;
    leslieLoad.load("les.txt");
    It worked but as you see it's kind of duplication of code .I
    decide to catch the instance name of the button name in a global
    varibale ,then I load the text file according to the name of the
    global varaible ,Now please tell me how can I get the name of the
    instance of the button when I click on it and please guide me in th
    is way.
    sincerely yours Mohsena

    are you using movieclip buttons or true buttons?

  • Application.cfc versus application.cfm

    HI I have application.cfc and applicaiton.cfm in one folder. I defined same global varibales in both files with different values. I am using same global  variables in my cfml files. When I call my cfml page which values will dispaly in my page?
    Advance Thxs

    Daverms is right. But Owain and Adam are also right - you should test these things to find out. It's a much better way to learn, it actually takes less time than to wait for an answer, and you're more likely to remember the answer.
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/
    Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
    GSA Schedule, and provides the highest caliber vendor-authorized
    instruction at our training centers, online, or onsite.
    Read this before you post:
    http://forums.adobe.com/thread/607238

  • @RELATIVE, single child and implied share - any conflicts there?

    Essbase version 11.1.2.1, BSO cube (with Planning), Implied share active:
    We have some calc scripts which stopped working, in EAS returning error:
    Error: 1042013 Network error [10054]: Cannot Receive Data
    Error: 1042012 Network error [10054]: Cannot Send data
    .xcp-files were created in the database folder, but we couldn't find any useful information there.
    Checked and tested several things without finding anything suspicious: Netdelay/Netretrycount, DB-properties, Essbase-disks, booted servers, restarted services, new Create from Planning, clear data/new import, retrieve/lock-send in Addin working fine ... Nothing seems wrong.
    So application works fine - except from a couple of calc scripts that one day "suddenly" stopped working. (Well, actually nothing really happens by itself, does it?)
    No changes in dimensions or application setup being made in advance.
    When looking further into one of the scripts, I found which piece of code that causes the error:
    EXCLUDE (N_I)
    FIX (@RELATIVE(N,0))
    EntityA = (EntityB * Factor->"N_I") * Factor->N;
    ENDFIX
    ENDEXLCUDE
    The Factor dimension looking like:
    N (Parent)
    N1 (Child of N)
    N10 (Child of N1)
    N_I (Child of N)
    Solution:
    I added a sibling to N10, so that N1 then had two children: N10 and N10_dummy.
    Then the scripts were running fine again. No network errors any more.
    Two questions, then:
    1) Is there a problem with this combination of Exclude, @RELATIVE and single child (N10)?
    2) This worked for a long time until now. Why suddenly a problem now? Could external changes (network, server environment) inflict on this?
    Best regards, Ann-M
    Edited by: Ann-M on Dec 13, 2012 2:09 PM
    Indents missing, added explanatory text

    Hi Ann,
    I must say good information provided and shared.
    From my experience what i can say is that
    using exclude, @RELATIVE and single child (N10) together should not create any issue.
    cause - the only thing i can see over here may be some of the global Varibale set to the application might be causing the issue.
    or may be some of the dimension got change later.
    Let me know if you still have any more questions.
    Thanks,
    KKT
    Please mark answers as helpful or correct for others to find easily

  • Automatically populate a tabular block

    I have an application with a lot of forms.
    All the forms are in differents files. SO, I use the Open_form() funnction to open my form.
    In my first form, I have a global varibale.
    In my second form, I need to use this GLOBAL varibale to populate AUTOMATICALLY a tabular block.
    But I don't know how to do that ...
    Can someone help me ?
    Tx in advance,
    Xav.

    Globals are not the best thing to use, but if you must heres an example.
    In WNFI trigger:
    DEFAULT_VALUE(NULL,'global.[global_name]')
    IF :global.[global_name] IS NOT NULL THEN
    l_default_where :=GET_BLOCK_PROPERTY('[block]', WHERE_CLAUSE);
    IF l_default_where IS NOT NULL THEN
    l_default_where := l_default_where | | ' AND ';
    END IF;
    l_default_where := l_default_where | | '([table_name].[item_name] = '| | :global.[global_name] | | ')';
    SET_BLOCK_PROPERTY('[block]', WHERE_CLAUSE, l_default_where);
    END IF;
    null

  • Scope of global & pl/sql variable in open_form with new session

    Hi,
    What will be the scope of the Oracle forms global variable & variable declared in a pl/sql pckage, if the value in these variable is updated from the Oracle Form GUI, if the form is opend by using the open_form method with new session or Active session.
    My requirement is , I developed one application with custom user login name & password - not the Oracle username & password.
    But I need to track the user actions on the forms - Inser/Update/Delete action, for this i included user_name as one of the column in the base table, and from the form, initialise this field with login user name.
    I implemented this in the trigger of the base table. But for delete, I am not getting the user name who deleted, only getting the user who created this record, because :NEW is not in scope for after delete trigger. So for the delte, I created a variabe in a PL/SQL package, and created two procedure to set & get the user name to that variable, and from the Form, before delete by using the set method I assign the current login user name to the variable, and in the trigger by using the get() get the user name from the variable, So far this is working fine, my doubt is What will be the value in the variable, if two different user made delete action from at a same time, Whether first user name will be replace with second one, or this variable will be in different session, If I opened the forms by using SESSION parameter. Also can I use Oralce Forms global varaible instead of the PL/SQL varibale.
    Thank in advance.

    Thanks Andreas,
    I did the same way. But my doubt is All the user login will be in different session, I mean, Whether the vairable used to store the user name will be in different session to each Oracle Forms user, it wont overwrite one user name with the next login user name.
    -- Copied from you old message:
    <<On the forms-side after the login, call PK_USER.PR_SET_USER(THE_USER_TAKEN_FROM_SOMEWHERE);
    In your db-triggers where you actually use something like USER, use PK_USER.FK_GET_USER instead>>
    Thanks
    Rizly

  • PSP GLOBAL VARIABLE

    I have a problem in Calling a Global Variable(s) That Was Defined in Package and Must be Use in All procedures of Package.
    I Descibe My Problem in Following Steps:
    - First I Define A Global Variable In Package Body.
    - Second Initialize The Values Of Variable In One Of Procedures of Package.
    - Third Call The Initalized Variable In Another Procedure.
    - Forth The Called Varibale don't Have Correct Value
    When use in a Http Address. For Exapmple :
    http://ora-server:7778/pls/psp/main.proc1
    Note : When use PL/SQl I Don't Have Any Problem About.
    Please Assist Me in as Soon as Possible.
    Thank You

    Mansoureh,
    I think you landed in the wrong forum. This one is for Oracle HTML DB.
    Scott

  • Global defination ...in smart forms..

    hi all  'smart forms' gurus...
    how to declare table fields in global defination wat is to rite under variable name and associated type..

    Hi,
    In 'Global Data' tab, variable name is name of internal tables or work areas or global variables etc...
    Ex:
    In 'Types' tab declare all user defined structures, data types.
    TYPES:
    BEGIN OF r_itab,
    vbeln TYPE vbrk-vbeln,
    vkorg TYPE vbrk-vkorg,
    vtweg TYPE vbrk-vtweg,
    spart TYPE vbrk-spart,
    fkdat TYPE vbrk-fkdat,
    END OF r_itab.
    In 'Global Data' tab, declare internal tables, work areas, global variables.
    Varibale name        Type assignment         Associated type
    ITAB                       TYPE TABLE OF         R_ITAB            <----- Internal table
    WA                         TYPE                         R_ITAB            <----- Work area
    VAR                        TYPE                          I                     <----- Variable

  • How do I pass local final variable value to global variable.

    Hi,
    In my code, I need to pass the local final string varibale value to the global variable for further usage. I know final is constant and inside the braces it can't be modified or assigned to other. Help needed in this regard or how do I re-modify the code according to my requirement i.e assigning the final string variable value to the outside of that block.I need the value of final String variable to be available in the process method outside of the specified block.
    class HostConnection{
    public module process(){
         HostKeyVerification hkv = new HostKeyVerification() {
              public boolean verifyHost(String hostname,SshPublicKey key) {
    final String keyfingerprint = key.getFingerprint();               return true;
    Thanks
    Sri                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    SriRaj wrote:
    It seems to be by-default all varibales in the inner calss method are Final.This is not true. Try this:
    class SomeClass {
      public void method() {
        Runnable runnable = new Runnable() {
           public void run() {
              int i = 0;  // new inner-class variable
              i = i + 1;
              System.out.println(i);  //prints "1"
    }But you obviously can't do this:
    class SomeClass {
      public void method() {
        Runnable runnable = new Runnable() {
           public void run() {
              int i = 0;  // new inner-class variable
              i = i + 1;
              System.out.println(i);  //prints "1"
        System.out.println(i); //compiler error: "i" is undefined
    }Because you are declaring i in an inner class. If you want to access the value of i outside that inner class, you'd have to do this:
    class SomeClass {
      private int i;
      public void method() {
        Runnable runnable = new Runnable() {
           public void run() {
              int i = 0;  // new inner-class variable
              i = i + 1;
              System.out.println(i);  //prints "1"
              SomeClass.this.i = i;
        System.out.println(i); //no compiler error
    }If this doesn't answer your question, please try to post an actual question, along with your real code, and any compiler errors you are getting, word for word.

  • Global data getting reset when running under IIS?

    We have a scenario using IIS with an ASP.NET web service written in VB.NET. When a call to the web service is made, the web service calls a native dll (written in C, compiled using VS2010) using platform invoke, which in turn calls into our product API:
    VB.NET web service -> native library (p/invoke) -> native API ....
    Web service requests are successfully completed and the system runs without problem for hours. A trace of the native API shows it is being called by multiple processes and multiple threads within those processes.
    The main native API dll contains a static global variable used to detect whether it is the first time it has been called and run initialization logic if it is. This dll is itself linked to a second dll that contains a global variable used to detect if it is
    the first time it has been called.
    After some hours the trace shows that the native API is invoked by an existing process but that the initialization logic is being exercised again, even though the global variable was set to indicate not first time and is never reset.  One theory was that
    the first process has ended and a new process has started almost instantaneously using the same process ID. However this is not the case as existing thread IDs from the same process are seen to write to the trace again after the first time logic has executed
    for the second time, indicating the process has not restarted. The problem occurs regularly.
    It is as though the process's global data has been initialized again and malloc'ed memory freed while the processing is still running. Is there any way this is possible when running under IIS?
    There is an internal thread which waits on a blocking read of a named pipe (via ReadFile), and when the problem occurs, the ReadFile call ends with ERROR_NO_ACCESS, which appears to indicate the malloc'ed buffer is no longer valid, again implying something
    has happened to the memory allocated to the process.

    Suggestting you asking it on:
    http://forums.iis.net/

Maybe you are looking for

  • What are the Tables effected after shipping done

    Hi all, What are ALL the tables will be effected when the oe_order_lines_all.flow_status_code=shipped confirm ? And what are the main shipping tables ? Thanks in advance

  • Windows script to start and stop jobserver only, with BOXI31

    hi, my question is easy but i have found nothing : on BOXI31 how  to start and stop jobserver (adaptive...) automaticaly with windows script ? in tasklist command, jobserver have no services name... thank's

  • How to transfer a document from pages 5.5.1 to iPhoto 9.6?

    I just got a new macbook from Santa.  A macbook pro  os x 10.10.1 In my older version of pages, when I was finished with a document I could press print and send the document to iPhoto as a picture. In the new version pages 5.5.1, how can I make a doc

  • My lightroom basic settings are set, and not zero'd out.  How do I fix it

    When I import photos, some of my sliders are already set.  I want them in the middle so I can adjust.  Specifically shadows and highlights are set to extremes.  How do I correct this?

  • The Dock

    Okay so when I want to quit from an app from the dock, it wont show that window where it says like quit this or whatever, so i have to go to the little apple thing and quit like that, and also whenever i open an app it doesnt bounce. Anyone know how