A question about the execution order of java code

I have a question about the order of the execution of java code.
class myclass
String str1 = new String("str1");
static String str2 = new String("str2");
static
String str3 = new String("str3");
myclass( )
String str4 = new String("str4");
static myfuntion()
String str5 = new String("str5");
When I new a myclass object, what is the order of execution about str1,str2.str3 ,str4?
When I run myclass::myfunction( ) instead of new a myclass object what is the execution order about str1, str2, str3, str4, str5?
Thanks

hello,
I think there may be one thing can't use println to make sure.
class myclass
static {  System.out.println("str1");   };
myclass() { System.out.println("str2"); }
then str1 appear before str2
class myclass
static {  String str1 = new String("str1"); };
myclass() { String str2 = new String("str2"); }
then
str1 initilized before str2,
str1 get the value str1----->after<----- str2.
Am I right or wrong?

Similar Messages

  • About the execution order

    I have a question about the execution order of the program, which bothers me for a long time.
    If anybody knows how to resolve it, please help me and thanks a lot.
    The code is very simple and as follows in class ExecutionOrder.
    I would like the output is:
    Thread is going to start!
    Thread is running!
    Thread is ended!
    But actually the output is always:
    Thread is going to start!
    Thread is ended!
    Thread is running!
    public class ExecutionOrder extends Thread 
        private static ExecutionOrder mainThread;
        public static void main (String[] args)
            mainThread = new ExecutionOrder ();
            mainThread.test();   
        public void test (){
            testStart();      
            mainThread.start();      
            testEnd ();
        public void testStart (){
          System.out.println ("Thread is going to start!");
        public void testEnd (){
          System.out.println ("Thread is ended!");
        public void run ()
            System.out.println ("Thread is running!"); 
      

    Resources for learning about threads:
    Java's Thread Tutorial
    JavaWorld: Introduction to Java threads
    IBM: Introduction to Java threads
    Google: java+threads+tutorial

  • Yet ANOTHER question about the Pre-Order

    When the IPAD came out, I selected the pre-order pick up at store option. With the IPAD, the policy was to get there before 3:00 or your reserved IPAD would be released to the anyone who wasn't pre-ordered. Does anyone know if this time is the same for the new IPhone?

    the confirmation email for the iphone said you had until the store closed on the 24th to pick it up or your reservation would be canceled and you would need to setup a new reservation.

  • How to find the Execution Time for Java Code?

    * Hi everyone , i want to calculate the execution time for my process in java
    * The following was the ouput for my coding,
    O/P:-
    This run took 0 Hours ;1.31 Minutes ;78.36 Seconds
    *** In the above output , the output should come exactly what hours , minutes and seconds for my process,
    but in my code the minutes are converted into seconds(It should not)...
    * Here is my coding,
        static long start_time;
        public static void startTime()
            start_time = System.currentTimeMillis();
        public static void endTime()
            DecimalFormat df = new DecimalFormat("##.##");
            long end_time = System.currentTimeMillis();
            float t = end_time - start_time;
            float sec = t / 1000;
            float min = 0, hr = 0;
            if (sec > 60) {
                min = sec / 60;
            if (min > 60) {
                hr = min / 60;
            System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
        }* How to Calcualte exact timing for my process....
    * Thanks

    * Hi flounder, Is following code will wotk perfectly?
         public static void endTime()
              DecimalFormat df = new DecimalFormat("##.##");
              long end_time = System.currentTimeMillis();
              float t = end_time - start_time;
              float sec = t / 1000;
              float min = 0, hr = 0;
              while(sec >= 60){
         min++;
         sec = sec -60;
         if (min >= 60){
         min = 0; //or min = min -60;
         hr++;
              System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
         }

  • Question about the order to creating Account, Contact, Contact Role

    Hi, my friends,
    I have some questions about the order of creating Account, Contact, Contact Role, etc in Web Service 1.0. I could create them in the following case:
    1. Insert Contact object and get contactId (now new contact exists in CRMOD)
    2. Insert Account object with Contact Role child associated with contactId
    My questions are:
    1. Do we have the following order? Insert new Account with new Contact child and Contact Role child (Contact is new and does not exist in CRMOD).
    2. Looks like system need accountId, contactId, etc to make the objects relationship. Is there other field having the same function?
    Thanks
    Ray

    Hi Ray,
    In response to your questions:
    1. Do we have the following order? Insert new Account with new Contact child and Contact Role child (Contact is new and does not exist in CRMOD).No. Both the Account and Contact must already exist. The Role value is an attribute on the Account Contact relationship, this relationship must exist in order to assign a role value to it. This is consistent with the behaviour of the UI, when you press the New button on the Contact child applet, you are taken to the Contact New page where you can create a Contact record. Once you save, the relationship is created but you cannot assign a role value unless you click the Edit Roles link next to the new Contact.
    2. Looks like system need accountId, contactId, etc to make the objects relationship. Is there other field having the same function?Correct, the system needs to know which Account/Contact pair is being assigned a role value. To do this the Account and Contact values must be uniquely identified using the Id values for each.
    I hope this helps.
    Thanks,
    Sean
    Edited by: Sean Duffy on Jan 25, 2010 10:11 AM

  • It does not cover my question about in what order does the sync work?

    It does not cover my question about in what order does the sync work?
    Does the first signed on computer copy its information to the cloud?
    Does the second computer/pad/cell then download the information from the cloud overwriting the information on the second device even if some of the information is different?
    What happens to the information on the second device that is not in the cloud?
    If you delete a record (eg a bookmark) from the second device how does it then delete it on the first device?
    What are the keys to the different types of information?

    Hi I have answered you questions inline below:
    Does the first signed on computer copy its information to the cloud?
    Yes when you first set up the account or when you first add a device to the cloud, if it is not the first time, it will merge with the other data
    Does the second computer/pad/cell then download the information from the cloud overwriting the information on the second device even if some of the information is different?
    By default it merges. There is no option to change this.
    What happens to the information on the second device that is not in the cloud?
    It will sync at the next sync interval if that data is selected to sync.
    If you delete a record (eg a bookmark) from the second device how does it then delete it on the first device? What are the keys to the different types of information?
    It resolved the entry the next time the first and second device syncs. Can you elaborate on the second part of this question?

  • A question about the impact of SQL*PLUS SERVEROUTPUT option on v$sql

    Hello everybody,
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0  Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>
    OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64I would like to ask a question about the SQL*Plus SET SERVEROUTPUT ON/OFF option and its impact on queries on views such as v$sql and v$session. Here is the problem
    Actually I define three variables in SQL*Plus in order to store sid, serial# and prev_sql_id columns from v$session in order to be able to use them later, several times in different other queries, while I'm still working in the current session.
    So, here is how I proceed
    SET SERVEROUTPUT ON;  -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files
    SET SQLBLANKLINES ON;
    VARIABLE mysid NUMBER
    VARIABLE myserial# NUMBER;
    VARIABLE saved_sql_id VARCHAR2(13);
    -- So first I store sid and serial# for the current session
    BEGIN
        SELECT sid, serial# INTO :mysid, :myserial#
        FROM v$session
        WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId');
    END;
    PL/SQL procedure successfully completed.
    -- Just check to see the result
    SQL> SELECT :mysid, :myserial# FROM DUAL;
        :MYSID :MYSERIAL#
           129   1067
    SQL> Now, let's say that I want to run the following query as the last SQL statement run within my current session
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;According to Oracle® Database Reference 11g Release 2 (11.2) description for v$session
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]
    the column prev_sql_id includes the sql_id of the last sql statement executed for the given sid and serial# which in the case of my example, it will be the above mentioned SELECT query on the employees table. As a result, right after the SELECT statement on the employees table I run the following
    BEGIN
        SELECT prev_sql_id INTO :saved_sql_id
        FROM v$session
        WHERE sid = :mysid AND serial# = :myserial#;
    END;
    PL/SQL procedure successfully completed.
    SQL> SELECT :saved_sql_id FROM DUAL;
    :SAVED_SQL_ID
    9babjv8yq8ru3
    SQL> Having the value of sql_id, I'm supposed to find all information about cursor(s) for my SELECT statement and also its sql_text value in v$sql. Yet here is what I get when I query v$sql upon the stored sql_id
    SELECT child_number, sql_id, sql_text
    FROM v$sql
    WHERE sql_id = :saved_sql_id;
    CHILD_NUMBER   SQL_ID          SQL_TEXT
    0              9babjv8yq8ru3    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;Therefore instead of
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;for the value of sql_text I get the following value
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);Which is not of course what I was expecting to find in v$sql for the given sql_id.
    After a bit googling I found the following thread on the OTN forum where it had been suggested (well I think maybe not exactly for the same problem) to turn off SERVEROUTPUT.
    Problem with dbms_xplan.display_cursor
    This was precisely what I did
    SET SERVEROUTPUT OFFafter that I repeated the whole procedure and this time everything worked pretty well as expected. I checked SQL*Plus documentation for SERVEROUTPUT
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Could anyone kindly make some clarification?
    thanks in advance,
    Regards,
    Dariyoosh

    >
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Hi Dariyoosh,
    SET SERVEROUTPUT ON has the effect of executing dbms_output.get_lines after each and every statement. Not only related to system view.
    Here below what Tom Kyte is explaining in this page:
    Now, sqlplus sees this functionality and says "hey, would not it be nice for me to dump this buffer to screen for the user?". So, they added the SQLPlus command "set serveroutput on" which does two things
    1) it tells SQLPLUS you would like it <b>to execute dbms_output.get_lines after each and every statement</b>. You would like it to do this network rounding after each call. You would like this extra overhead to take place (think of an install script with hundreds/thousands of statements to be executed -- perhaps, just perhaps you don't want this extra call after every call)
    2) SQLPLUS automatically calls the dbms_output API "enable" to turn on the buffering that happens in the package.Regards.
    Al

  • Question about the programming of a legend

    Hello everybody,
    I have a question about the programming of a waveform's legend. I
    already asked here in this forum about the legend programming (03)
    months ago.
    I went satisfied but I ve just noticed that this code
    (See Code old_legend_test.llb with main.vi as main function) operates a
    little different from my expectances.
    Therefore I have a new question and I want to know if it
    is possible by labview programming to plot and show, on a waveform
    chart, a signal with activ plot superior to zero (0) without to be
    obliged to plot and show a signal with activ plot equal to zero (0) or
    inferior to the desired activ plot.
    I give you an example
    of what I m meaning. I have by example 4 signals (Signal 0, 1, 2 and 3)
    and each signal corresponds respectively to a channel (Chan1, Chan2,
    Chan3, Chan4). I want to control the legend (activ plot, plot name and
    plot color) programmatically. Is it possible with labview to plot signal
    1 or 2 or 3 or (1, 3) or (2,3) or (1,2,3) or other possible combination
    without to active the signal with the corresponding activ plot zero
    (0)?
    Let see the labview attached data
    (new_legend_test.llb with main.vi as main function). When I try to
    control the input selected values again I get them back but I don't
    understand why they have no effect on the legend of my waveform chart.
    Could somebody explain me what I m doing wrong or show me how to get a
    correct legend with desired plots? Thank by advance for your assistance.
    N.B.
    The
    both attached data are saved with labview 2009.
    Sincerly,PrinceJack
    Attachments:
    old_legend_test.llb ‏65 KB
    new_legend_test.llb ‏65 KB

    Hi
    princejack,
    Thanks for
    posting on National Instruments forum.
    The behavior
    you have is completely normal. You can control the number of row displayed in
    the legend and this rows are linked to the data you send to your graph. Thus,
    if you have 3 arrays of data, let say chan1, chan2 and chan3, you can choose
    which data you want to display in your graph using the property node (Active
    plot and visible). But for the legend as you send 3 plots there is an array of
    the plot name [chan1, chan2, chan3] and you can display 0, 1, 2 or 3 rows of
    this array but you cannot control the order in this array! So, to be able to
    change this array you have to only send data you need to you graph. I'm not
    sure my explanations are clear so I have implemented a simple example doing
    that.
    Benjamin R.
    R&D Software Development Manager
    http://www.fluigent.com/
    Attachments:
    GraphLegend.vi ‏85 KB

  • I want to question about the official service at the service center of Sony.

    I want to question about the official service at the service center of Sony.
    long since I like the models and items sony. from start playstation, cameras, camcorders up, I've ever had. and a new camera that I bought two years ie compact cameras Sony Cybershot DSC H200. as of a month ago, a camera was having problems in lenses that would not close. and setting the automatic mode to move by itself. I came to the Sony Service Center in Makassar, precisely on Jl. Shop Pengayomann A5 / 05 (0411) 442340.
    operator initially said only two weeks to work on my camera. but this week has been more dau even want to go in a month tomorrow, dated July 9, no news from the service center. and I kept the call to the office service. as well as assorted reasons. there are no spare parts or technical constraints, and the last one I call to his office, he said the factory spare part is damaged. imported directly from Singapore. I think, ko new spare part it can be damaged before using that? how the quality of this Sony spare part? ugly? not good? why?
    I was disappointed with this situation, where soon it will Eid, want to return home as well to Java. but the camera has not been settled workmanship?
    nah, roughly what is the solution of the Sony plagued with this problem? please help, because he did not know to whom to complain. operator had just said: it's up to the father alone.
    once again I asked for his help. solution. if you can before Eid arrived.
    Thank you,
    AD. Rusmianto

    Hi awwee107, 
    Welcome to the Sony Community! 
    We have forwarded your query to the relevant team for their further assistance and someone from local CC will contact you.
    Thanks!
     

  • The question about the sharepoint server 2010 install

    Hi Friends,
    i have a question about the sharepoint server 2010 install. 
    my computer is used the windows server 2008 service pack 1. in order to install the sharepoint 2010 server, i need to choose to windows server 2008 service pack 2. my question is when i install the windows server 2008 service pack 2,whether the inside
    of my computer  information will be lost or change? 
    thank you in advance. 
    Qearl

    Hi ,
    No data will be lost either from your Windows program files or other drives as long as it is an upgrade.
    After upgrade you will still be able to see your old program files under windows.ol folder in the C: Drive of the new OS.
    The data will be lost only when you perform a clean install like complete formatting the HArd disk and installing from scratch.
    As mentioned it always good to maintain a backup preferable important files in a skydrive as there is a good chance of external drives crashing.

  • I got an answer and I replied with a question about the answer, does no show in unanswered

    I got an answer and I replied with a question about the answer, does no show in unanswered questions. I guess replying was not the way to get another anwer, How do I do that?
    He said - Certain Firefox problems can be solved by performing a Clean reinstall. This means you remove Firefox program files and then reinstall Firefox.
    I want to know - Will I still have my bookmarks, history, addons, plugins, etc.? I do not know what plugins and such that I had. What about my pinned tabs and my tabs that where open.
    More information - When I try to start Firefox I keep getting the message that I need to restart my computer in order to complete a previous update attempt. I had Sweetpacks on my PC and I do not know where it came from, it took over my home page in Internet Explorer and Ithink caused the issue with Firefox.
    Should I do the clean install or try starting Firefox now.

    Could you please stay in the thread where you posted the question and reply there instead of opening a new thread?
    Locking this thread, so please continue here:
    *[[/questions/968194]]
    See also:
    *[[/questions/968222]]
    You won't lose bookmarks and other data in the Firefox profile folder as long as you do not remove personal data in case you uninstall Firefox.
    See also:
    *http://kb.mozillazine.org/Profile_backup
    *https://support.mozilla.org/kb/Backing+up+your+information
    You can open the Properties of the Firefox desktop shortcut via the right-click context menu and check the "Compatibility" tab.<br />
    Make sure that all items are deselected in the "Compatibility" tab of the Properties window.

  • Question about the sequence structure

    Hi,
    If we want to get best performance when programming a sequence of functions or calculations, we should choose 'Stacked sequence structure' or 'Flat sequence structure'? or they have the same performance?
    Thanks.

    To the best of my knowlege there is no performance hit, the "Flat sequence structure" was a fairly recent addition to try and overcome one (of many) complaints about sequence structures in general, that stacked sequences obscure what is happening in the code. If the various sections of your calculation or functions have data dependency, i.e. the output of a calculation is fed into the subsequent calculation or function, then a sequence structure is probably not needed as, with data flow, the calculation that is "dependent" won't executed until all its inputs requirements are satified. If the "functions" are in the form of sub-vi's the method that is more "proper" is to inforce a dependency between subsequent vi's. This can be as simple as adding error in and out controls to the sub-vi's, even if they are only passed through the vi without actually performing an error function. This allows you to wire them together in the execution order that is required. Doing this on some of the early "built-in" functions that have remained in LabVIEW (the original timer functions) sometime requires putting a wrapper around them to make them sub-vi's with error passing, but in the latest versions of LabVIEW the compiler seems to do a good job of minimizing any performance hits this might appear to cause.
    Putnam Monroe
    LabVIEW Evangelist since 1992
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Question about the function module (RFC_READ_TABLE)

    Dear everyone
    Could I ask you a question about the function module (RFC_READ_TABLE)?
    I was asked if it's possible to create a report which compares the data between different SAP systems (both production systems).
    Now, the easiest way would be to use the function module (RFC_READ_TABLE) within a SAP infoset query (SQ01 type query).
    But I heard the rumor that using the function module (RFC_READ_TABLE) is not advisable due to the security reason.
    However, I am not exactly sure what sort of security problems this function module can possibly have...
    Would you help me on this?
    I also would like to know if using "remote enabled module" type function module can always overcome this possible security issue.
    Or, are there any points that I need to be careful about even when I use "remote enabled module" function module?
    Thank you very much in advance.
    Takashi

    Dear Fred-san
    Thank you very much for your support on this.
    But, may I double check about what you mentioned above?
    So, what you were mentioning was that if some user executes the query with
    the function module (RFC_READ_TABLE), under the following conditions, he can access to
    the HR data even when he does not have the authorizations for HR transactions?
    <Conditions>
    1. the user has the authorization for HR database tables themselves
    2. RFC_READ_TABLE is called to retrieve the data from HR database
    <example>
    Data: LF_HR_TABLE like  DD02L-TABNAME value 'PA0000'.
    CALL FUNCTION 'RFC_READ_TABLE'
       EXPORTING
        query_table                = LF_HR_TABLE
      TABLES
       OPTIONS                    =
       fields                     =
       data                       =    .
    But then, as long as we call this function module for a non-critical tables such as
    VBAP (sales order) or EKKO (purchase order) within our query, it wouldn't seem to be
    so security risk to use RFC_READ_TABLE...
    Besides, each query (infoset query) has got the concept of user groups, which limits
    the access to the queries within the user group.
    ※If someone does not belong to the user group, he cannot execute the queries within that
       user group, etc
    So, my feeling is that even infoset queries does have authorization concept...
    Would you give me your thought on this?
    I also thank you for your information for SCU0.
    That is an interesting transaction
    Kind regards,
    Takashi

  • Muvo V200, question about the play m

    Hello,I have a question about the play mode on my V200. I want to play the songs in a specific order (like in a playlist) but I don't find the way to do this. Can you help me please ?
    Thanks
    (sorry if I don't speak english very well, but I'm french )

    Hi!
    To get the tracks to play in a specific order, put numbers at the beginning of each file name. E.g.: file 'examplesong.mp3' would become '0_ examplesong.mp3' Don't spend years doing that manually though; the computer will do it for you! Click on 'my computer', then click on 'Muvo V200 media explorer'.. This shows the contents of your player. Choose the folder that you want to reorder the songs in...
    ( it's best to put the songs in folders, like you would in a floppy disk, as the muvo can only hold a certain amount in the root directory, and folders are great for organisation - eg: you can put one CD in each folder, and then the player will play all of the tracks in that folder before moving on to the next one )
    ...and click on it to display the songs. In the pictures along the top of the window, 4th from the right is an icon with a downward facing arrow and an A above a Z. Click on this, it's called 'custom sort'. You can then use the arrows at the bottom to change the order of your tracks to how you want them. Click OK, and they'll all be numbered (and so will play) in that order.
    Hope that helps!
    x

  • A question about the XS key

    Hi,
    I have a quick question about the XS key used for Logic. Now, the XS key is a small piece of hardware and it is very susceptible to being misplaced or lost.
    If someone were to lose the XS key, how would one be able to obtain another XS Key? Would that person need to buy Logic all over again? Or can they make a special order to get another one based on proof of ownership of Logic?
    it's just a small question.
    thanks
    -Justin

    There have been threads about this recently if you search for them.
    I think someone said they got theirs replaced for about $80.

Maybe you are looking for

  • Sso from webdynpro app (on WAS  2004s ) to BW web template ( on BW portal )

    Guys - We want to give BW Web template(running in 'Y' BW portal server ) as IFrame or URL Link in Webdynpro application ( Running in server X - WAS 2004s). We had setup SSO between java stack of X to Java stack of Y. but when i open url link,it is st

  • SOS:     Exit for ME51n/ ME52n/ ME53n/

    hello erverybody, at First i would like to implement the exit mm06e007 but i have no idea how to do it!! have someone an example, coding or Tips,... ?? Second Problem : how can I Overwrite the <u>Tapstrips name</u> using exit MEREQ001 ?? please i nee

  • Runtime error :COMPUTE_BCD_OVERFLOW

    Hi,    I am getting the run time error as "Overflow for arithmetical operation (type P) in program". Here is the part of my code. Types:  begin of ty_nriv,          OBJECT    type NROBJ,          SUBOBJECT type NRSOBJ,          NRRANGENR   type NRNR,

  • OSX 10.6.8 hangs: troubleshooting tips?

    Hello All Using a MacPro1,1 Dual-Core Intel Xeon, 7 Gb ram and plenty hard disk space. My Mac recently started to hang. I have the beach ball appearing randomly and computer freezes for a number of seconds. It is not like a rogue process is hogging a

  • How to make high resolution image?

    Hi All, I am in an urgent requirement where I have few .tif images. There size is very high. When I am uploading, there resolution is not good and they are automatically converted to jpg. Can some one tell me "How to make this image high resolution i