How to count the number of objects created...

How many String objects will be created(With explanation please...)
String s1="abc";
s1.concat(s1);
s1.replace('a','z');
Any help on this will be highly appreciated.
Thanks

anox wrote:
To give this thread a little more value:
Is there a way to know how many objects were generally created/in use by your program?No. Unless you cound accessing debug information (I'm not even sure you can find it there).

Similar Messages

  • How to find the number of references created for a given  object ??

    How to find the number of references created for a given object in a big application environment.
    That means, if i give any object name (of my application) as input, then how can i find the[b] number of references created for that particular object ??

    Please do not post the same question multiple times.
    As for your original question, there is no direct way to do it.
    Especially not the way you phrased it,
    since objects don't have "names".
    Applications also don't have "names".
    They have classes and instances.
    Also, there are 2 related issues, and I'm not sure which one is the one you asked.
    #1. Finding the number of references to the same object.
    Eg.
    Map<String,String> a = new HashMap<String,String>();
    Map<String,String> b = new HashMap<String,String>();
    Map<String,String> c = a;In this case, there are only 2 objects.
    The first object has (at least) 2 references pointing to it.
    The second object has (at least) 1 reference pointing to it.
    (There may be more, if the HashMap library keeps
    references to these things, or if the HashMap object has
    some internal cyclic references...)
    If you're asking this, then it can't be done.
    It's an active research topic in universities
    and software research labs, called "alias analysis".
    Type it in google, and you'll see people are working hard
    and having little success so far.
    #2. Finding the number of instances created from a class.
    In this case, what you have to do is to add a counter to
    the constructor of the class. Every time an object is constructed,
    you increment the counter. Like this:
       class MyClass
           public static int counter = 0;
           public MyClass( )  { counter++; }
        // Then later in your program, you can do this:
        MyClass a = new MyClass();
        MyClass b = new MyClass();
        System.out.println(MyClass.counter); // It should show 2Note: you won't be able to do this to every class in the system.
    For every class you care about, you have to modify its constructor.
    Also: when an object is deleted, you won't always know it
    (and thus you won't always be able to decrement the counter).
    Finalizers cannot always work (read Joshua Bloch's
    "Effective Java" book if you don't believe me), but basically
    (1) finalizers will not always be called, and
    (2) finalizers can sometimes cause objects to not be deleted,
    and thus the JVM will run out of memory and crash

  • How to count the number of rows in a resultser object?

    hi there
    how to count the number of rows in a resultser object which may contains millions of rows? besides using a while loop? thanks

    You don't, you execute a query whose result is the record count of those records that match the search and then you execute the actual query to create your record set. Typically you do
    select count(id) from YourTable where [filter]
    from the resulting ResultSet do
    int res.getInt(1);
    which gives you the count and then
    select id from YourTable where [filter]
    to produce the actual result set.
    in the second query the id part can be substituted with the actual fields you want.

  • How to count the number of lines dynamically,

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES
    The display function is:
    FORM DISPLAY_DATA .
      ULINE.
      WRITE :  /1 SY-VLINE, 'check',
                10 SY-VLINE, 'Plant',
               20 SY-VLINE, 'Material number',
               50 SY-VLINE, 'Follow up material',
               70 SY-VLINE, 'Safety stock',
              100 SY-VLINE, 'Partc'.
      ULINE.
      LOOP AT IT_MARC.
        MOVE: IT_MARC-WERKS TO IT_REC-WERKS,
              IT_MARC-MATNR TO IT_REC-MATNR,
              IT_MARC-NFMAT TO IT_REC-NFMAT,
              IT_MARC-EISBE TO IT_REC-EISBE,
              IT_MARC-PARTC TO IT_REC-PARTC .
        APPEND IT_REC.
        CLEAR IT_MARC.
      ENDLOOP.
      DATA: GV_TABIX TYPE SY-TABIX.
      LOOP AT IT_REC.
        GV_TABIX = SY-TABIX.
        READ TABLE GT_TOTAL WITH KEY WERKS = IT_REC-WERKS
                                     NFMAT = IT_REC-NFMAT.
        IF SY-SUBRC EQ 0.
          IT_REC-PARTC = GT_TOTAL-PARTC.
          MODIFY IT_REC INDEX GV_TABIX TRANSPORTING PARTC.
        ENDIF.
      ENDLOOP.
      LOOP AT IT_REC.
        WRITE : /1 SY-VLINE, IT_REC-CHECK AS CHECKBOX,
                10 SY-VLINE, IT_REC-WERKS,
                20 SY-VLINE, IT_REC-MATNR,
                50 SY-VLINE, IT_REC-NFMAT,
                70 SY-VLINE, IT_REC-EISBE,
               100 SY-VLINE, IT_REC-PARTC.
        AT END OF NFMAT.
          ULINE.
        ENDAT.
      ENDLOOP.
      ULINE.
    ENDFORM.                    " DISPLAY_DATA
    Solved

  • How to count the number of wins?

    I have a tic tac toe simulator that simulates a game of tic tac toe (obviously). I press the 'play' button, and 1 random X and O is placed in 9 of the labels. Then the application says if X or O wins, or if the game was a tie/no winner.  So,
    what I want to do is when I click the 'exit' button, I want a message box telling the user how many times X won, O won, and how many ties there were.  I am not too sure how to count the number of wins.
    -Thanks

    Thanks for the reply.  I could be wrong, but I do not think that is exactly what I am looking for.  Here is the code that I have that determines the winner:
    switch (checkWinner())
    case 'T':
    winnerLabel.Text = "It was a tie!";
    break;
    case 'O':
    winnerLabel.Text = "O Wins!";
    break;
    case 'X':
    winnerLabel.Text = "X Wins!";
    break;
    private char checkWinner()
    char WinnerChar = ' ';
    int winning_line = 0;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[1]) && GameBoardCellChar[0].Equals(GameBoardCellChar[2]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[3].Equals(GameBoardCellChar[4]) && GameBoardCellChar[3].Equals(GameBoardCellChar[5]))
    WinnerChar = GameBoardCellChar[3];
    winning_line++;
    if (GameBoardCellChar[6].Equals(GameBoardCellChar[7]) && GameBoardCellChar[6].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[6];
    winning_line++;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[3]) && GameBoardCellChar[0].Equals(GameBoardCellChar[6]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[1].Equals(GameBoardCellChar[4]) && GameBoardCellChar[1].Equals(GameBoardCellChar[7]))
    WinnerChar = GameBoardCellChar[1];
    winning_line++;
    if (GameBoardCellChar[2].Equals(GameBoardCellChar[5]) && GameBoardCellChar[2].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[2];
    winning_line++;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[4]) && GameBoardCellChar[0].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[2].Equals(GameBoardCellChar[4]) && GameBoardCellChar[2].Equals(GameBoardCellChar[6]))
    WinnerChar = GameBoardCellChar[2];
    winning_line++;
    if (winning_line == 0 || winning_line > 1)
    WinnerChar = 'T';
    return WinnerChar;
    Do I have to include something extra in here to get the count or no?
    The code I posted is the coding in my play button.

  • How to count the number of text boxes that are data entered

    How to count the number of text boxes that are data entered in visual basic form.

    Here is an Iterator that expands on my previous response:
    ''' <summary>
    ''' Iterator for form controls
    ''' </summary>
    ''' <param name="onlyControlsOfType">specify type if a certain type of controls needed</param>
    ''' <param name="onlyTopLevel">if true don't search containers within the form</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Iterator Function AllControls(Optional onlyControlsOfType As Type = Nothing, _
    Optional onlyTopLevel As Boolean = False) As IEnumerable(Of Control)
    Dim ctrl As Control = Me.GetNextControl(Me, True)
    Do Until ctrl Is Nothing
    If onlyControlsOfType Is Nothing OrElse ctrl.GetType = onlyControlsOfType Then
    If TypeOf ctrl.Parent Is Form OrElse Not onlyTopLevel Then
    Yield ctrl
    End If
    End If
    ctrl = Me.GetNextControl(ctrl, True)
    Loop
    End Function
    Some sample uses:
    For Each
    For Each c As Control In AllControls()
    Debug.WriteLine(c.Name)
    Next
    List of all controls, including controls in containers i.e. Groupbox
    Dim l As List(Of Control) = AllControls().ToList
    List of all Textbox controls, including Textboxes in containers i.e. Groupbox
    l = AllControls(GetType(TextBox)).ToList
    List of all Textbox controls, don't include Textboxes in containers i.e. Groupbox
    l = AllControls(GetType(TextBox), True).ToList
    'Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it.'  JohnWein
    Multics
    My Serial Port Answer

  • How to retrict the number of object that a class can have...

    hi
    i m just writing a banking program and each customer can only have
    2 accounts,,,so i need to restrict the number of account object that a customer
    can have,,
    so i need to count object? or something like that so that when a customer
    try to create more account, i need to stop them. but
    i don't know how to do that....
    customer can only have two accounts, and,,,,how do i know
    if customer already have two accounts...........................

    i m just writing a banking program and each customer
    can only havePlease make the extra effort to write out words such as "am". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership.
    >
    so i need to count object? Yes. The customer can possess a reference to each account. If the customer has two accounts, the customer can register no more.
    i don't know how to do that....
    The Java� Tutorial - A practical guide for programmers
    customer can only have two accounts, and,,,,how do i
    knowBy counting the number of accounts a customer has!
    P.S. What's with the repeated punctuation?

  • How to count the number of Rows to be Updated before Update takes place..

    Hi all,
    I have a requirement, where i have to count the number of rows to be updated before updating it. SQL%ROWCOUNT gives the no. of rows updated ( after update takes place). How do i get to know the count of no. of rows to be updated/inserted/ deleted. I was looking for a simple solution, as above SQL%Rowcount. But i couldn't find any. I can use a Function and Return the value which will give me number of rows to be updated, But is there any Simple Logic other than this.. or any count function. Your Help is Appreciated. Thanks!

    If you really want to do this (I have no clue why you would need it), then you can piggy back on any existing pessimistic locking you may already have in place.
    However, it would require two loops through the records of which you want to know the count before you update, and a second pass to update them.
    I would really re-think the need for this, though.
    SQL> create table t0304(c number);
    Table created.
    SQL> insert into t0304 select rownum from all_objects where rownum <= 10;
    10 rows created.
    SQL> commit;
    Commit complete.
    SQL> select * from t0304;
             C
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.
    SQL> declare
      2    cursor mycursor is select * from t0304 where mod(c,2) = 0 for update;
      3    i number := 0;
      4  begin
      5    for r in mycursor loop
      6      i := i + 1;
      7    end loop;
      8    dbms_output.put_line(i);
      9    for r in mycursor loop
    10      update t0304 set c = c + 20 where current of mycursor;
    11    end loop;
    12  end;
    13  /
    5
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL> select * from t0304;
             C
             1
            22
             3
            24
             5
            26
             7
            28
             9
            30
    10 rows selected.
    SQL>Edited by: Steve Howard on Mar 4, 2011 5:57 PM

  • How to count the number of rows in a cube!!??

    Experts,
    I can somebody tell me how do I count the number of rows in my cube when i am using listcube???..
    Thanks
    Ashwin

    Hi,
    have a look ath this theard too
    Number of Records in Cube
    regards

  • How to Count the number of TAB chars value '0A' in a line?

    I have a requirement to count the number of TABs in a text file that I am processing (they must equal 75) to ensure that all the fields have been submitted on the file I am reading?
    How do I identify the TABs in a line?
    I have this so far:
             CONCATENATE gv_unix_file gv_lstfiles-name INTO gv_unix_file.
              OPEN DATASET gv_unix_file for INPUT IN TEXT MODE ENCODING NON-UNICODE.
              IF sy-subrc <> 0 .
                message e000(zz) with 'Cannot access in_uk files'.
              ENDIF.
              CONCATENATE gv_unix_file_arc gv_lstfiles-name INTO gv_unix_file_arc.
              OPEN DATASET gv_unix_file_arc FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
              IF sy-subrc <> 0 .
                message e000(zz) with 'Cannot access in_uk files'.
              ENDIF.
              DO.
                READ DATASET gv_unix_file into lv_str.
                IF sy-subrc <> 0.
                  exit. "exit do loop, file is done.
                else.
                  TRANSFER lv_str to gv_unix_file_arc.
                ENDIF.
              ENDDO.

    Here is a sample code:
    DATA: lv_string TYPE string,
          lv_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
          lv_i TYPE i.
    DATA: result_tab TYPE match_result_tab.
    DO 3 TIMES.
      CONCATENATE 'A' lv_string INTO lv_string SEPARATED BY lv_tab.
    ENDDO.
    " this is how you need to find how many tabs are in your transfer work area...
    FIND ALL OCCURRENCES OF lv_tab IN lv_string RESULTS result_tab.
    DESCRIBE TABLE result_tab LINES lv_i.
    WRITE:'No. of tabs found:', lv_i.

  • How to count the number of cycles in sine wave

    Hi,
    I am new to Labview.  I have labview 8.2 version and my dataacquisition is NIDAQPAD6015.  I could write a program to generate a sine wave of desired frequency through simulate signal. My question is how do i measure the number of cycles for this sine wave as soon as I run the program. Hope my question  is clear.
    Ravi Mokirala

    To find the offset (which in this case is the Y value midpoint around which the sine wave is symetrical):
    Capture more than one cycle.  Find the min and max values.  Subtract Min from Max and divide by 2.  Then subtract this result from the Max value (or add the result to the Min value).  This is the offset.
    To count the number of cycles where the offset is unknown, just use the first data point value as a reference.  If the next data point is more positive, then count the number of times that the first data point is repeated and the next data point is more positive.  Of course with DBL data type, you probably would not get the exact same value as the first data point, so you need to use In Range with a very tiny limit.  It all depends on your signal amplitude, frequency, and sampling rate.
    Example:  Lets say your first data point value is 0.5 and the 2nd point is 0.55.  You need to look for another value that is between 0.48 and 0.52.  Then read the very next data point value.  If it is greater than the previous value, add one to the cycle count.  If it is less than, you are at half a cycle, do not add to the count.
    - tbob
    Inventor of the WORM Global

  • How to count the number of 'True' outputs from an 'Equal?' function?

    In my program, I have an 'Equal?' function which returns 'True' whenever x=y. How can I count the number of 'True' and display? I mean, for example, when it say True, the counter should display '1', when it say true next time the counter should display '2', like wise 3, 4.... so on. Can any one help me to do this? Is there any function which conts and display the number of 'true' outcomes?

    Is your event structure in a while loop?  Then that's where the shift register can go.  But for portability a feedback node can be used if the VI is not reentrant.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How to count the number of deleted rows processed

    Sybase ASE version: 15.7-SP52
    Hi all,
    I have a delete statement that will potentially delete millions of rows
    DELETE from TAB_A where COL_A='Y'
    The delete is long, at some point I'd like to know how many rows were deleted.
    If I do SELECT COUNT(*) from TAB_A where COL_A='Y', the query should be locked because of the exclusive-lock held by the DELETE in progress.
    If this is the case, how can I actually count the number of rows deleted so far?
    Thanks all
    Simon

    Simon
    For  deleting significant number of rows best practice is to delete rows in small batches of known size (e.g. 10 K) inside a while loop. 
    This keeps transaction log from filling up as well.
    Also between two iterations of delete you can give some wait to make sure that you do not monopolize the server. Sleep could be for a fixed number of seconds (e.g. 5) or for randomized number say from 1 to whatever makes sense.
    Typically "set rowcount " is used to set up the batch size and "waitfor delay" to sleep between iterations.
    Global variable @@rowcount gives yo actual rows deleted. For the last batch this may be lower than the batch size you set up.
    HTH
    Avinash

  • How to count the number of instances a record appears in a string

    I have a move that imports Name, Department and Site from an
    external CSV file, this part I managed to get working after many
    weeks. I would like to be able to count the number of instances of
    a specific Site “Glasgow” appears in the String. This
    way I know how many lines to set.
    Also can you add Dynamic text to a rollover button? I can get
    the the text to display on the root but not on a button.
    I am new to programming and Flash so apologies in
    advance.

    Those which took time to read carefully *_iWork Formulas and Functions User Guide_* are aware of the availability of wildcard characters.
    =COUNTIFI(range;"=text")
    will do the trick.
    Yvan KOENIG (VALLAURIS, France) lundi 26 avril 2010 17:36:34

  • How to count the number of characters

    Dear All,
                Can anyone tell me a Function Code or sample code to count the number of charactes in a text.
    Regards,
    Vijay

    hi
    <b>use the inbuilt function strlen</b>
    Number of characters in arg; blanks at the end of data objects with a fixed length are not counted, although they are counted in type string data objects. If you use a non-Unicode double-byte code, a character that occupies 2 bytes is counted twice.
    <b>example</b>
    data: v_len type i,
    v_str type string value 'gggugik'.
    v_len = strlen( v_str ).
    write:/ v_len.
    Regards,
    ravish
    <b>plz reward points if helpful</b>

Maybe you are looking for

  • Ipod video is not recognized by windows

    and it says it doesnt have a driver please help

  • Not able to download all Audio Contents from Logic Pro 9

    Hi! I want to download the sound libraries that come with Logic Pro 9 (I know I am a little bit late). The most Jam Packs are already downloaded and installed but I have problems with downloading of one of the packages, the additional Sounds for Logi

  • Price unchangable

    HI, i'm creatimng credit memo request with reference to milestone billing; copy control setting is maintained from billing to sales order(creditmemo request) item category TAO, Price is getting copied from billing say 1000 to credit meme request; but

  • Next / forward button quit working

    I was cleaning up my HD, transferred iTunes folder to external HD. Dragged & dropped files back into music lib, now the forward/back buttons don't work. Files play when clicked/opened directly, but won't move to next song. PPC G4, 1.25ghz, 1.25gsram,

  • How to buy itunes gift card?

    today, i can't buy gift cards on iTunes, please help me how to buy itunes gift card???