"abstract" modifier for local variable

Again, I am studying the SCJP 6 and have a question on avaiable access modifier in local variable (within the method).
The book said the ONLY access modifier allowed for variable within the method is "final", and for method-local inner class is "abstract" or "final". But for fun I tried to write this code:
public class NewClass1 {
    public static void method1(){
        abstract String a = "hello";
        System.out.println(a);
    public static void main(String[] args){
        method1();
}can it compiles and runs fine. Also when I change to this below, I can even "change" the value of a refer to, the behaviour seems ignoring the final access modifier:
public class NewClass1 {
    public static void method1(){
        abstract final String a = "hello";
        a = "free to change the value";
        System.out.println(a);
    public static void main(String[] args){
        method1();
}So my question are:
1. Can local variable use the access modifier "abstract"?
2. If yes, what is the meaning of it?
Edited by: roamer on 2009?11?16? ??9:55

it compiles and runs fine
As I said in the post they were compiled and ran without any error or exception.
Yes, when "compiling", I got the compilation error which is same to your message^^
let's see if I got the same error again in my home.I've seen your future, and it's got a compiler error in it.

Similar Messages

  • Memory (RAM) model in Flex or ActionScript for local variables in a method

    I have a method in AS3 to handle certain event generated from some Components in <mx:Repeater>. Two different Components can fire the same event
    at the same time so the same method must handle the two events together. My question is if the two calls on the same event handler method will step on each other. The event handler method only uses the local variables.
    In Java, the local variables of a method for the two callers are in two different memory (RAM) addresses. So they will not step on each other. Not sure about
    Flex/ActionScript.

    Actionscript runs in a single thread.  One of the events will get fully
    processed before the other.

  • Create Type NI_MultipleNumericLimitTest for local variable

    I am using  Multiple numeric test in my seq &  documenting in case of   Seq fail
    i.e when the  value is not in the limits
    I am using for-each-loop step type for this
    I want  a Local variable  of type  NI_MultipleNumericLimitTest      in my foreach (current element ) 
    but am not able to generate   a local of tht type!!
    what   measures to take to do so

    You cannot create a variable of a step type.  Step types can only be used to create steps.
    What is your goal?  Maybe there is a better way to accomplish what you want.
    If you are looking to dynamically change the limit set you need to use other types like NI_LimitMeasurmeent or an array of those.
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Local variable

    Hallo,
    In a VI I have to modify a local variable. In the original Version its value is beeing set by a control. I want to replace the control by a for-loop. Then the loop changes the value and I needn't change the control for 100 times.
    But when I do that, the variable doesn't change its value. What am I doing wrong? By the way, this is the first time, I work with variables.
    Arno

    Hi,
    I can answer the question myself:
    I made a for-loop which gives the variable a number. This array of values I sent to the "old input", not forget to index the array. Then it worked.
    Arno

  • Local variable's VariableElement not accessible through treepath

    Hi,
    I'm extending TreePathScanner visitor to localize and handle certain annotations associated with variables of any kind (field, parameters and local variables).
    To do so I overrode the visitVariable method that, as far I understand, should be able to obtain the corresponding javax.lang.model's VariableElement for any variable (whatever its kind) based on the current three path, see code bellow.
    It does work well with fields and parameter, however with local variables Trees.getElement simply returns a null. All the information is in fact in the code tree VariableTree node and I could retrieve what I needed from it but rather refrain from using com.sun. ... API if not really necessary and of course implement the processing twice.
    Perhaps the javax.lang.model.... object tree is not built for elements within a method body? or is this a bug? com.sun.source.util.Trees#getElement javadoc only says that a null is returned if the element is not "available".
    Thanks in advance.
    import javax.lang.model.element.VariableElement;
    import com.sun.source.util.TreePathScanner;
    import com.sun.source.util.Trees;
    import com.sun.source.tree.VariableTree;
    import com.sun.source.util.TreePath;
    public class MyVisitor extends TreePathScanner<Object,Trees> {
         @Override
         public Object visitVariable(VariableTree node, Trees trees) {
              TreePath path = getCurrentPath();
              VariableElement ve = (VariableElement) trees.getElement(path);
              if (ve != null) {
                            // The case for parameters and fields.
                            process(ve);
              else {  // Funnily getElement return null for local variables
                            process(node);
              return super.visitVariable(node, trees);
    }

    I had a similar problem where trees.getElement(TreePath) was returning null. In my case it had to do with the fact that symbol resolution wasn't done yet. I was trying to invoke my TreePathScanner after calling javacTask.parse() but I had to switch to after calling javacTask.analyze() otherwise trees.getElement(TreePath) always returned null. My issues was with a TreePath for a method though.

  • Which way is used to allocate/deallocate memory for locals?

    Good afternoon.
    I would like to know how memory is allocated/deallocated for local variables in an activation record/frame. For example, in the following java code:
    1 public void test()
    2 {
    3     {          
    4          {
    5               String y = "abc";
    6          }
    7     }
    8     {
    9          String y = "pqr";
    10     }
    11 } At line 5, memory is allocated for variable y. Is this memory deallocated at line 6 (right after its declaration block), or after the line 11 at which point the whole activation record for the method is popped out of the stack?
    In addition, is this local memory allocation/deallocation strategy required by the Java specification, or could be different with different Java compilers? Thank you very much and have a great weekend,
    Sunny

    Hi,
    Thank you for your comments!
    Perhaps I did not state my problems clearly. Here is my real purpose: I am trying to monitor a program's runtime behavior by dynamically maintaining an object graph where nodes represent runtime objects and directed edges represent "refer to" relation between objects. To better understand my questions, let me first briefly introduce my algorithm to update the object graph:
    1. add an edge (between objects): when a local refers to an object, add an edge from the enclosing object to the referred object
    2. delete an edge: when a local refers to another new object, delete the edge from the enclosing object to the previously referred object; or the memory allocated for this local is deallocated.
    For example, if I have the following Java method,
    1 m()
    2 {
    3        {
    4                 Object x = objA;
    4'                x = objB;
    5                 // some statements
    6        }
    7        {
    8                 // some statements
    8'                Object x = objC;
    9        }
    10 }Below, the enclosing obj means the object containing the method m().
    At line 4, a local name x is declared and assigned objA, at which point an edge from the enclosing obj to objA should be added. At line 4' the same local is assigned a new value, at which point we should delete the edge from the enclosing obj to objA and add a new edge to objB.
    At line 6 this local is out of its scope, whether or not we should delete the edge from the enclosing obj to objB depends on whether the memory allocated for x is deallocated.
    Lastly, at line 8' a new local with the same name x is declared so we should add a new edge...
    Another example is like this:
    1 m1()
    2 {
    3      Object x = objA;
    4     // some statements
    5     m2();
    6 }
    7 m2()
    8 {
    9     Object x = objB;
    10     // some statements
    11 }After line 9, I should be able to know the enclosing obj has two outgoing edges labeled with x, one is to objA and the other is to objB.
    Is there any solution to getting this runtime information for Java local variables? I would really appreciate any help!
    -- Sunny

  • Local variable initialization

    How local variables initialized in CVI?
    Are there any default values for local variables?

    Following function is generated by IVI Scope driver generator.
    If the vertical coupling is GND, variable simOffset is used in an equation without being initialised.
    Is this a bug and it must be initialized?
    * Function: TTTTT_FetchWaveformSafe
    * Purpose: This function returns the data from the instrument. You must
    * range-check all parameters and lock the session before calling
    * this function.
    static ViStatus TTTTT_FetchWaveformSafe (ViSession vi, ViConstString channelName,
    ViInt32 waveformSize, ViReal64 waveform[],
    ViInt32 *actualPoints, ViReal64 *initialX,
    ViReal64 *xIncrement)
    ViStatus error = VI_SUCCESS;
    if (!Ivi_Simulating (vi)) /* call only when locked */
    ViSession io = Ivi_IOSession (vi); /* call only when locked */
    ViChar rdBuf[5000];
    checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE));
    /*=CHANGE: ==============================================================*
    Do actual instrument I/O only if not simulating. Example:
    viCheckErr( viPrintf (io, ":WAV %sATA?", channelName));
    viCheckErr( viRead (io, rdBuf, 5000, VI_NULL));
    Change the number of elements in the rdBuf array as appropriate for your
    instrument's maximum record size.
    Convert the rdBuf raw data here to a double precision floating point
    numbers and store the data in the waveform array.
    Read the waveform preamble from the instrument to get the initial X
    and X increment values.
    If the oscilloscope did not resolve all points in the waveform record,
    replace such points with the IVI_VAL_NAN value. The function should
    return the TTTTT__WARN_INVALID_WFM_ELEMENT
    warning in this case.
    *============================================================END=CHANGE=*/
    else
    ViInt32 x;
    ViReal64 yRange, simOffset;
    ViInt32 triggerSlope, vCoup;
    ViReal64 k, level, theta, offset;
    checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL,
    TTTTT_ATTR_HORZ_RECORD_LENGTH,
    0, actualPoints));
    checkErr( Ivi_GetAttributeViReal64 (vi, channelName,
    TTTTT_ATTR_VERTICAL_RANGE,
    0, &yRange));
    checkErr( Ivi_GetAttributeViInt32 (vi, channelName,
    TTTTT_ATTR_VERTICAL_COUPLING,
    0, &vCoup));
    checkErr( Ivi_GetAttributeViReal64 (vi, channelName,
    TTTTT_ATTR_VERTICAL_OFFSET,
    0, &offset));
    checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL,
    TTTTT_ATTR_TRIGGER_SLOPE,
    0, &triggerSlope));
    checkErr( Ivi_GetAttributeViReal64 (vi, VI_NULL,
    TTTTT_ATTR_TRIGGER_LEVEL,
    0, &level));
    checkErr( Ivi_GetAttributeViReal64 (vi, VI_NULL,
    TTTTT_ATTR_HORZ_TIME_PER_RECORD,
    0, xIncrement));
    checkErr( Ivi_GetAttributeViReal64 (vi, VI_NULL,
    TTTTT_ATTR_ACQUISITION_START_TIME,
    0, initialX));
    theta = asin (2*level/yRange);
    if (triggerSlope == TTTTT_VAL_POSITIVE)
    k = 1.0;
    else
    k = -1.0;
    if( *actualPoints>waveformSize )
    *actualPoints = waveformSize; /* Checking number of points to write */
    *xIncrement /= *actualPoints;
    if (vCoup == TTTTT_VAL_DC)
    simOffset = 0.5;
    if (vCoup == TTTTT_VAL_GND)
    k = 0.0;
    for (x = 0; x < *actualPoints; x++)
    ViReal64 y = simOffset + k * 2.5 * sin (*xIncrement * 12560 * x + k * theta) + // ~2 periods of 1kHz sinewave
    (!(x%20)) * (16384 - rand())/150000.0;
    waveform[x] = (offset + yRange/2) > y ? ((offset - yRange/2) < y ? y : (offset - yRange/2)) : (offset + yRange/2);
    Error:
    return error;

  • Local variable modification/access events in JPDA?

    Dear Folks,
    I am wondering if I can monitor modification/access events for local variables in JPDA. I used to use JDI as a tool to implement my project, but unfortunately there were only modification/access events for fields. Could someone tell me whether JVMTI (or any other tool from Sun) supports this?
    Another problem when I was using JDI is that given an ObjectReference, I was not able to retrieve the underlying object in the target VM? Does there exist any solution to this problem?
    Thank you very much for your help!
    Sunny

    Hello,
    There are no such JVM TI watchpoint events yet.
    Please, see the RFE:
    4228507 Add local variable and array element watchpoints
    Thanks,
    Serguei

  • Local variable table missing

    I have compiled my sources using IBM's jikes compiler with the -g option (for debugging purposes). I am using Sun's JRE 1.2.2. and JPDA 1.0.
    When I run the debugger using JPDA and try to set a watch for local variables I get an error saying that the local variable table is missing. And it asks me to compile the source with the debug option (which I've already done but with the jikes compiler)
    Any ideas what is going wrong here?
    Thanks,
    Rahul.

    Simplest/quick solution would be to recompile with sun's javac before you run it through sun's JRE.

  • Debugger issue - local variable table missing

    I have compiled my sources using IBM's jikes compiler with the -g option (for debugging purposes). I am using Sun's JRE 1.2.2. and JPDA 1.0.
    When I run the debugger using JPDA and try to set a watch for local variables I get an error saying that the local variable table is missing. And it asks me to compile the source with the debug option (which I've already done but with the jikes compiler)
    Any ideas what is going wrong here?
    Thanks,
    Rahul.

    How about using javac?

  • Are the read and write operations atomic for an array in a local variable.

    Hi,
    I would like to know when you access an array in a local variable, is it an atomic operation?
    Thanks,
    Mat

    Thanks for the comments. I agree with you. However, I my case, race conditions and synchronization are not issues. Therefore, the only thing that matters to me is that the write and read operation of the array must be atomic. I know that I can implement that with a LV2 style global but I want to avoid it if possible.
    If writing and reading to an array are atomic operations then I can simply use local or global variables.
    All I need to know is: Is reading or writing an array in a local variable an atomic operation?
    Thanks,
    Mat

  • How to specify a unique integer for each local variable defined in TestStand?

    I have a .net application that reads all TestStand local variables, but for the .net application each local variable should have a unique integer number. Iterating through the locals and storing the index is not a good solution, because if a local variable is moved or deleted, the index will change.
    Does anyone know how to do this in TestStand or having an idea how to this in my .net application?
    Thanks.

    Thanks Doug for your reply. Using a GUID is not an option because this ID is too long. I will try to explain why I need this ID for. I have a lot of C# code that generates code to deal with a lot of instruments. For example to configure a device, user defined variables can be used to specify some settings or to store results. These variables are not stored in the generated code with a name but with an integer number. Now I want to try to be use all our existing device driver code with the TestStand sequencer. So, I need a translation between the name of a TestStand local variable and an integer number. After constructing the interface to my code I want to read all the variables from TestStand and now I need the integer ID to do the mapping to my variables. I know that I can use use your proposition 2 by encoding the unique ID into the name of the variable and parse the name of the variable to get it back, but this is not an automated way. This will be rather difficult if there are several hundreds of variables. For this reason I am looking for an alternative way. Looking forward for your response. Best regards   

  • How to add a new Local Variable for DataBase Logging?

    Hello
    I need to add a Local sequence variable to my STEP_RESULT table, i know i need to modify the schema by adding a new column but not sure on what to write in "Expression" to access the value of local variable. 
    Please reply asap, as its a little urgent.
    Regards
    Nitin Goel

    Hi
    you can read this here:
    http://digital.ni.com/public.nsf/allkb/F5ADBC61222343B586256CE00055E6D6?OpenDocument
    Regards
    DianaS

  • Local variable for an Array of fixed size

    Hello,
    I have a two multirate loops in a VI. 
    In one loop, I want to refer an fixed sized array initialized in the other loop.
    But I coudn't name the array, so I can't refer it.
    Is there any way to refer it?
    Thanks,
    Young.

    If you need a local variable, there is no other way than to create an indicator for it.
    In LabVIEW there is no "fixed length" array : you can always add or remove an array element, and you don't need to declare it as in other languages. They are intrinsic dynamic objcets. Of course, the memory manager has to cope with this, that's why it's often better to initialize an array, to give it its final size immediately, resulting in faster running programs. However, this is only noticeable with relatively large arrays (> 10000-100000 elements).
    May be you should explain in more details what you intend to do, because trying to reproduce a C approach in LV is probably not the best thing to do. For instance, you said that you are initializing your array in a first loop. You mean that you re-initialize the array at each iteration ? I suppose no, so may be you could put the initialize step out of the loop, and wire the array to your two parallel loops.
    Remember also that local variables are not always good programming solutions, since using them will generate copies of their content each time they are refered to. And that can low down your program very significantly...
    Message Edité par chilly charly le 11-05-2005 05:05 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Shall I use global or local variables for my program?

    Hello,
    1) I am using 2 while loops in parallele. One 50 ms timed and the other one 1000 ms. The 50 ms one gets data from a sensor. I want to display that data every 1000ms in the 1000 ms loop. I have used global variables to do that. Should I better use local variables?
    2) This question deals with the VI I have attached
    a)  Shall I initialise the "  Quitter programme " global variable in the main VI aswell ? Or is what I have done enough?
    b)
    I want the sequence to continue ( finishes the last sequence and goes back to the first one without any delay if possible ) until the user presses Quit. I am concerned about the " wait until " icon of the exterior main while loop ( set to be 250 ms at the moment ). This time, 250 ms, is the time it takes between the end of the last sequence and the beginning of the first sequence? Is that right? Once u start the first sequence, the while loop doesn’t do anything until the end of the last sequence ( my 3 sequences can take several minutes ) ?
    Hope I am clear… lol
    Don’t hesitate to ask any questions if not clear enough
    thanks a lot,
    David
    Attachments:
    Example1.zip ‏28 KB

    Bonjour Marc.  You will definitely have a race condition because you are writing to the global in a parallel loop.  You could click the stop button in the quitter program, then before it is read in the main loop, the lower loop writes a false to it, and your click is lost.  Why do you want a separate quitter program?  You may have a good reason but it isn't clear here.  I would not use globals or locals for this, just put your stop button on the main vi.  You already have one, so why do you want another one in another vi?  If you must do it this way, eliminate both lower loops.  They are not necessary.  The global default is set to false, so when you run the vi, it is false.  The button mechanical action is set to latch when released, so after clicking it will turn true until the main vi reads it, then it will automatically turn false.  So you don't need the lower loops to keep writing false to it.  If you just eliminate both lower loops, it will work fine.  The only purpose I could see for the quitter vi is to have one button cause several vi's to stop.  Instead of doing it this way, put one stop button in your main vi, create a reference (right click - create - reference), and wire this reference into all subvi's that the main calls.  The subvi's must be changed to accept the reference and use it.  This would be a much better method to close all vi's with one button.
    You could also get rid of the sequence structure (it hides code and makes it more difficult to read).  Just put all your code side by side.  The error in/out wire will ensure that the execution order will be fixed, just like in your first sequence with the open file and write file functions.  Just wire the error out of the write vi to the second write vi, and then the error out of the second write vi to the close vi.  No sequence structure needed, and all your code is viewable on one screen.
    - tbob
    Inventor of the WORM Global

Maybe you are looking for

  • Preferences Errors and Lots of software crashes...

    Heys, I am very new to this forum, so if this is in the wrong place I apologize! I have a White MacBook (plastic cover, not aluminum or pro) that I bought in 2008, stupidly, I never got time machine up and running on it. I recently switched to a newe

  • Info about

    Hi, Presetnly I am working with FBL1N  Transaction. Vendor Line Item Display. I would like some one to elaborate on that the usage of this transaction  FBL1N. Actually when I am passing the Vendor A/c it should be posted to WBS element, but it is get

  • HT201412 ipad will not do anything but show apple icon ?

    ipad will not do anything but show apple icon help please ?

  • Acrobat 8 Professional Batch Processing Problem

    When i try to make a batch processing command using Crop Pages the Apply To: drop down box is grayed out. I need to apply the crop page to the odd pages but because the box is grayed i cannot select this option. Is there something i can do to make th

  • How configure this new podcast awful 2.1 version

    I would like to know the conf of this new version 2.1 to not download automatically my aleady read episod (that I keep on mly iMac) on my iPhone !!! I don't have more 500 Go on my iPhone !!! And I want to keep all my podcast on my iMac ! Why is this