How many java String objects are created in string literal pool by executin

How many java String objects are created in string literal pool by executing following five lines of code.
String str = "Java";
str = str.concat(" Beans ");
str = str.trim();
String str1 = "abc";
String str2 = new String("abc").intern();
Kindly explain thanks in advance
Senthil

virtuoso. wrote:
jverd wrote:
In Java all instances are kept on the heap. The "String literal pool" is no exception. It doesn't hold instances. It holds references to String objects on the heap.Um, no.
The literal pool is part of the heap, and it holds String instances.
[http://java.sun.com/docs/books/jvms/second_edition/html/Overview.doc.html#22972]
[http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.html#67960]
You're referring to the JVM. That's not Java.It's part of Java.
There is nowhere in Java where it is correct to say "The string literal pool holds references, not String objects."

Similar Messages

  • How many Objects are created in this?

    Hi,
    How many objects are created in the flwg code:
    String str = new String("Hello");
    String str2 = "Hey there";
    str = str + str2;

    Depends if you're counting objects created at compile time.
    "Hello" is created at compile time. That's 1.
    new String("Hello") creates a new String object at runtime, pointing its backing array at the "Hello" in the constant pool. That's 2.
    "Hey there" is created at compile time. 3.
    str + str2 I might do everything at compile time, or it might do some at runtime. I don't know if str is considered a compile time literal here. I think not, but I'm not sure. You can check by using javap. If I'm correct, then at runtime you'll create a StringBuffer (4) and another String (5).
    So I'd say 5 objects. But if the compiler treats str as a literal and therefore can do the str+str2 at compile time, then it might do so without creating the StringBuffer. Or it might still create it at compile time, use it, and throw it out.

  • How many objects are created?

    I have this question which some one posted to me.
    He asked me how many objects are created when an object of a simple class is created for example
    class A{
    public static void main(String args[])
    A a1 = new A();
    Now how many objects are created? I think only one. Can anyone tell me if any other objects are also created.
    Plz tell me .

    No, the answer is indeed 1. All the other objects
    (including the String[] in the main method
    parameters) are created outside of the A
    class, either by the JVM itself or by some other
    class that calls the A.main() method. You can try
    this out for yourself by adding a constructor such as
    A()
    System.out.println("Creating class A");
    } and see what prints out.Take a closer look at the question:
    how many objects are created when an object of a
    simple class is created for exampleIt doesn't say "how many objects of type A are created".
    I.e. The VM has to load class A before you can create an object from it, and thus an object of type Class is created. There are also a bunch of other objects which needs to be created before you can instantiate A.
    Kaj

  • Y in java objects are created on heap only and not on stack ??

    Hi ,
    I need a answer to the question " why all the objects are created on heap only in java and not on stack " ?
    In java a object is created when we specify new i.e. for example,
    consider the following cases.
    1.
    Vector v = new Vector();
    here object is created and the reference to this object is assigned to variable v. okie.
    2.
    when i write something like
    Vector vec ;
    Here i am creating reference variable for Vector. No object is created and no seperate memory is allocated for it. Reference variablesa are stored along with other primitive variables on the java stack.
    My question is, in C++ by writing case 2 i can create an object and it is creating this object on stack. So why in java object is not created on stack while i do like this ? Why in java objects are created on heap only ?
    If my question is out of interest of this forum i apologize for it. But if somebody can throw some light on it, it would be of great help.
    Cheers !!
    Dipesh

    Hi
    I asked this question just to understand how compiler and jvm cud have been designed......i.e. to know the philosophy behind designing language.......
    now what i cud surmise is that if objects were to be stored in stack then on calling garbage colllector , it may delete some unused obj and unreferenced object(unreachable object) and this in turn may give rise to non-contagious areas in stack, thus nullifying the garbage collector's objective of freeing the the memory. Again deallocating that intersperse spaces into one free block of space will be bit troublesome task.....
    So considering above factor the designer of jvm and java compiler have opted for storing objects on heap rather than stack.....
    If u have something to say bout this.......pls go ahead.......
    Cheers !!
    Dipesh

  • Y in java objects are created on heap only n not on stack ?

    Hi ,
    I need a answer to the question " why all the objects are created on heap only in java and not on stack " ?
    In java a object is created when we specify new i.e. for example,
    consider the following cases.
    1.
    Vector v = new Vector();
    here object is created and the reference to this object is assigned to variable v. okie.
    2.
    when i write something like
    Vector vec ;
    Here i am creating reference variable for Vector. No object is created and no seperate memory is allocated for it. Here this reference is placed on the java stack along with other primitive data types.
    My question is, in C++ by writing case 2 i can create an object and it is creating this object on stack. So why in java object is not created on stack while i do like this ? Why in java objects are created on heap only ?
    If my question is out of interest of this forum i apologize for it. But if somebody can throw some light on it, it would be of great help.
    Cheers !!
    Dipesh

    Cross post!
    http://forum.java.sun.com/thread.jsp?forum=32&thread=260589

  • How many softMotion references can you create on an Interface Object

    I'm wondering how many softmotion references I can create on an interface object.  For example can I create a straight line move on an axis, keep that reference open then at the same time create another line move referece on a coordinate space that using that same axis?
    Can I have multiple line move references open at the same time on the same axis?
    Thanks,
    SteveA
    SteveA
    CLD
    FPGA/RT/PDA/TP/DSC

    Thanks Paul,
    I have noticed that the SoftMotion express vis open a reference on first call, but they never close the reference.  On my machine I will be doing regular coordinate moves and from time to time I will need to perform an Axis move.  Would it be better practice to close each reference after I perform the move?  How much overhead does it take to create a new reference?  The thought I had on keeping multiple reference open was to minimize the overhead in opening a reference.  Once my system gives a trigger to perform a move, I need it to be very responsive.
    Thanks,
    Steve
    SteveA
    CLD
    FPGA/RT/PDA/TP/DSC

  • How many sub-interfaces we are able to create with ISR 4321 ?

    Hi,
    I want to buy an ISR 4321 router. I would like to know how many sub-interfaces we are able to create with this router (802.1Q) ?
    http://www.cisco.com/c/dam/en/us/products/collateral/routers/4000-series-integrated-services-routers-isr/at-a-glance-c45-732425.pdf
    Thanks.
    Regards,
    Nurul Kabir KHAN

    Hello Nurul,
    The maximum number of interfaces (physical, subinterface, or virtual) a router can handle depends on the maximum number of SWIDBs that the router can use. This limit used to be set to 300 for all platforms, but with the emergence of features such as frame-relay subinterfaces, multilink Point-to-Point Protocol (PPP), and virtual private dial-up network (VPDN) that uses virtual interfaces, this value has proven to be insufficient on some platforms
    Maximum Number of interfaces
    Every interface uses an IDB. Therefore, the IDB limit indicates the maximum number of interfaces a router can handle.
    The IDB limit is, therefore, the answer to the common question "How many (sub)interfaces can be configured on this platform?"
    For further details, you can read this document
    Please don't forget to rate and mark as correct the helpful post!
    David castro 
    Regards,

  • How many server nodes can you create per instance

    Hi,
    Very often the bottle neck in a java installation (NW04s) is the heap size. In order to increase the heap you simple create new server nodes.
    My question is:
    How many server nodes can you create per instance?
    Is there an upper limit before you have to create a new dialog instance (with a web dispatcher)?
    I can imagine that when you create a new server node you also have to increase the heap and max therad of the dispatcher. Is there any upper limit of the heap size of the dispatcher node ?

    Rasmus , I think you laid out a real good scenario for every one to contribute
    I may be very late but just updating this forum for benefit of everyone who visits this.
    In addition to all the points above one must also consider following things if one decides to add more server nodes to one dispatcher
    1.Garbage collection time
    2.Dispatcher would keep on sending request to node S2 if it is not completely bad and there by impacting all the servernode       so  you might end up restartiing the entire cluster.
    3,Debugging also becomes diffculy as you are not sure on which server node you are within the cluster.
    4.If you have something like F5 which does hear beat monitoring even one server node goes bad F5 will not report anything.
    So in my view one server node per dispatcher is an ideal configuration.
    Over All Dispatcher does not consume more resouces (Disk Space + CPU + memory ) at the same time it will give you maintenance flexibility.
    Nothing is right or wrong ,all these things are based on how your infrastructure set up is.
    Cheers !!
    Manish Jain

  • Function to calculate how many working date there are.

    Good morning,
    there is a Function/Object to calculate how many working days there are between two dates?
    thanks
    M

    If you have problems finding in the forum the answer to this question, please re-post it and mention how you searched and how the results didn't help.
    Thread locked.
    Rob

  • How many notes(annotations) there are? Is detection possible?

    I can create move notes from code but first I must know how many text Notes there are in a document.
    Is it possible using executeActionGet(ref) ?

    I must know how many text Notes there are in a document.
    Is it possible using executeActionGet(ref) ?
    Not directly, however it seems that a work-around is possible.
    The following code is adapted from a snippet written by the brilliant Paul Riggott; it works for me in CS4:
    ps-scripts.com • View topic - Annotation functions.
    function hideAnnotation (index)    // Dummy action, only used to test the existence of an annotation by index...
        var exists = true;
        var desc = new ActionDescriptor ();
        var ref = new ActionReference ();
        ref.putIndex (stringIDToTypeID ('annotation'), index);
        desc.putReference (stringIDToTypeID ('target'), ref);
        try
            executeAction (stringIDToTypeID ('hide'), desc, DialogModes.NO);
        catch (e)
            exists = false;
        return (exists);
    function getAnnotationCount ()
        var index = 0;
        while (hideAnnotation (index))
            index++;
        return index;
    alert (getAnnotationCount ());
    HTH,
    --Mikaeru

  • How many  types of joins are there?

    how many  types of joins are there?
    Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:58 PM

    Hi,
    Joins are used to fetch data fast from Database tables:
    Tables are joined with the proper key fields to fetch the data properly.
    If there are no proper key fields between tables don't use Joins;
    Important thing is that don't USE JOINS FOR CLUSTER tableslike BSEG and KONV.
    Only use for Transparenmt tables.
    You can also use joins for the database VIews to fetch the data.
    JOINS
    ... FROM tabref1 INNER JOIN tabref2 ON cond
    The data is to be selected from transparent database tables and/or views determined by tabref1 and tabref2. tabref1 and tabref2 each have the same form as in variant 1 or are themselves Join expressions. The keyword INNER does not have to be specified. The database tables or views determined by tabref1 and tabref2 must be recognized by the ABAP Dictionary.
    In a relational data structure, it is quite normal for data that belongs together to be split up across several tables to help the process of standardization (see relational databases). To regroup this information into a database query, you can link tables using the join command. This formulates conditions for the columns in the tables involved. The inner join contains all combinations of lines from the database table determined by tabref1 with lines from the table determined by tabref2, whose values together meet the logical condition (join condition) specified using ON>cond.
    Inner join between table 1 and table 2, where column D in both tables in the join condition is set the same:
    Table 1 Table 2
    A  B  C  D    D  E  F  G  H 
    a1  b1  c1  1    1  e1  f1  g1  h1 
    a2  b2  c2  1    3  e2  f2  g2  h2 
    a3  b3  c3  2    4  e3  f3  g3  h3 
    a4  b4  c4  3    -
    Inner Join
    A  B  C  D  D  E  F  G  H 
    a1  b1  c1  1  1  e1  f1  g1  h1 
    a2  b2  c2  1  1  e1  f1  g1  h1 
    a4  b4  c4  3  3  e2  f2  g2  h2 
    Example
    Output a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
    DATA: DATE LIKE SFLIGHT-FLDATE,
    CARRID LIKE SFLIGHT-CARRID,
    CONNID LIKE SFLIGHT-CONNID.
    SELECT FCARRID FCONNID F~FLDATE
    INTO (CARRID, CONNID, DATE)
    FROM SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID AND
    FCONNID = PCONNID
    WHERE P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / DATE, CARRID, CONNID.
    ENDSELECT.
    If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or a table alias.
    In order to determine the result of a SELECT command where the FROM clause contains a join, the database system first creates a temporary table containing the lines that meet the ON condition. The WHERE condition is then applied to the temporary table. It does not matter in an inner join whether the condition is in the ON or WHEREclause. The following example returns the same solution as the previous one.
    Example
    Output of a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
    DATA: DATE LIKE SFLIGHT-FLDATE,
    CARRID LIKE SFLIGHT-CARRID,
    CONNID LIKE SFLIGHT-CONNID.
    SELECT FCARRID FCONNID F~FLDATE
    INTO (CARRID, CONNID, DATE)
    FROM SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID
    WHERE FCONNID = PCONNID
    AND P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / DATE, CARRID, CONNID.
    ENDSELECT.
    Since not all of the database systems supported by SAP use the standard syntax for ON conditions, the syntax has been restricted. It only allows those joins that produce the same results on all of the supported database systems:
    Only a table or view may appear to the right of the JOIN operator, not another join expression.
    Only AND is possible in the ON condition as a logical operator.
    Each comparison in the ON condition must contain a field from the right-hand table.
    If an outer join occurs in the FROM clause, all the ON conditions must contain at least one "real" JOIN condition (a condition that contains a field from tabref1 amd a field from tabref2.
    In some cases, '*' may be specified in the SELECT clause, and an internal table or work area is entered into the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the FROM clause, according to the structure of each table work area. There can then be gaps between table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, not simply by counting the total number of fields. For an example, see below:
    Variant 3
    ... FROM tabref1 LEFT OUTER JOIN tabref2 ON cond
    Effect
    Selects the data from the transparent database tables and/or views specified in tabref1 and tabref2. tabref1 und tabref2 both have either the same form as in variant 1 or are themselves join expressions. The keyword OUTER can be omitted. The database tables or views specified in tabref1 and tabref2 must be recognized by the ABAP-Dictionary.
    In order to determine the result of a SELECT command where the FROM clause contains a left outer join, the database system creates a temporary table containing the lines that meet the ON condition. The remaining fields from the left-hand table (tabref1) are then added to this table, and their corresponding fields from the right-hand table are filled with ZERO values. The system then applies the WHERE condition to the table.
    Left outer join between table 1 and table 2 where column D in both tables set the join condition:
    Table 1 Table 2
    A  B  C  D    D  E  F  G  H 
    a1  b1  c1  1    1  e1  f1  g1  h1 
    a2  b2  c2  1    3  e2  f2  g2  h2 
    a3  b3  c3  2    4  e3  f3  g3  h3 
    a4  b4  c4  3    -
    Left Outer Join
    A  B  C  D  D  E  F  G  H 
    a1  b1  c1  1  1  e1  f1  g1  h1 
    a2  b2  c2  1  1  e1  f1  g1  h1 
    a3  b3  c3  2  NULL NULL NULL NULL NULL
    a4  b4  c4  3  3  e2  f2  g2  h2 
    Example
    Output a list of all custimers with their bookings for October 15th, 2001:
    DATA: CUSTOMER TYPE SCUSTOM,
    BOOKING TYPE SBOOK.
    SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
    SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
    INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
    BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
    BOOKING-BOOKID)
    FROM SCUSTOM LEFT OUTER JOIN SBOOK
    ON SCUSTOMID = SBOOKCUSTOMID AND
    SBOOK~FLDATE = '20011015'
    ORDER BY SCUSTOMNAME SBOOKFLDATE.
    WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
    BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
    BOOKING-BOOKID.
    ENDSELECT.
    If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or using an alias.
    Note
    For the resulting set of a SELECT command with a left outer join in the FROM clause, it is generally of crucial importance whether a logical condition is in the ON or WHERE condition. Since not all of the database systems supported by SAP themselves support the standard syntax and semantics of the left outer join, the syntax has been restricted to those cases that return the same solution in all database systems:
    Only a table or view may come after the JOIN operator, not another join statement.
    The only logical operator allowed in the ON condition is AND.
    Each comparison in the ON condition must contain a field from the right-hand table.
    Comparisons in the WHERE condition must not contain a field from the right-hand table.
    The ON condition must contain at least one "real" JOIN condition (a condition in which a field from tabref1 as well as from tabref2 occurs).
    Note
    In some cases, '*' may be specivied as the field list in the SELECT clause, and an internal table or work area is entered in the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the llen in der FROM clause, according to the structure of each table work area. There can be gaps between the table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, as in the following example (not simply by counting the total number of fields).
    Example
    Example of a JOIN with more than two tables: Select all flights from Frankfurt to New York between September 10th and 20th, 2001 where there are available places, and display the name of the airline.
    DATA: BEGIN OF WA,
    FLIGHT TYPE SFLIGHT,
    PFLI TYPE SPFLI,
    CARR TYPE SCARR,
    END OF WA.
    SELECT * INTO WA
    FROM ( SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID AND
    FCONNID = PCONNID )
    INNER JOIN SCARR AS C
    ON FCARRID = CCARRID
    WHERE P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / WA-CARR-CARRNAME, WA-FLIGHT-FLDATE, WA-FLIGHT-CARRID,
    WA-FLIGHT-CONNID.
    ENDSELECT.

  • How many standard business roles are there in CRM

    Hi Experts,
    I had a question in one of my exam.. please answer it
    question:- How many standard business roles are there in CRM?
    options were:- 2,3,4,5
    I think the options does not have the right answer , upto my knowledge it is more than 5. please help me with the appropriate answer
    Thanks
    Rahul Mathur

    Hi,
    There are approximately 40 standard business roles available in the latest version ehp3.
    As the version changes the business roles increases. Initially  there are only 3 std business roles..
    1.sales pro 2. marketing pro 3. service pro and along with IC Agent.
    Each BR above is loaded with huge no of transactions even though our aim is to for ex: create sales order...we use sales pro but all the sales related operations(transactions) are being loaded in to the system so along with the version improvements/releases SAP have divided each of these std BR as much as they can and thus the no of operations or transactions per BR is decreasing with each release....
    Thanks & Regards,
    Malleswar.

  • ?? About how many downloads the apps are getting

    If anyone can help, it would be appreciated. Either first hand knowledge or information you have heard or read would be fine.
    I am doing market research and wonder how many application/game downloads are really occuring in the App Store/iTunes for iPhones/iPod Touch devices. I know how many total downloads they have (200 million), but any only concerned with Paid Apps/Games. So if anyone can answer these questions or share some light, thanks
    1) How many of the 200 million downloads are from paid apps
    2) Does anyone know how many paid downloads it takes to take the #1 spot daily, #10 spot, #25 spot, and #50 spot
    3) How many apps/games have you paid for, and how many free ones have you downloaded.
    Thanks again.

    jdawson1960
    Your posting is clearly outside the stated purpose of these forums and your user account is being blocked on that account.
    This is a Java forum, not a market research site.
    db

  • At max how many logical columns can be created in RPD

    Hi All,
    At max how many logical columns can be created in RPD. I have a requirement of creating 200 columns. Will there be any problem .
    Is there any predefind number of columns for RPD creation??
    Please help ..

    Hi Annapurna,
    There's no limit that I'm aware of or which is mentioned anywhere. Just as an example: I have a logical fact table with around 750 logical columns (>500 original measures & 250 derived measures). No issue whatsoever. Opening the presentation table through answers takes about 2-3 seconds (the NQSQL command has a lot to retrieve), but that's about it.
    Cheers,
    C.

  • How many types of ports are there which we use for data transfe in ale/idoc

    friends let me know how many types of ports  are there which we use for transfering
    data in ale/idocs?

    Hello,
    you can use file port,trnasactional RFC port.FI you are using IDOC-XML conversion combination,then you can XML port also.
    Thanks

Maybe you are looking for

  • File or Folder does not exist

    I'm having a wierd problem with a png image which generates an error in my script. I'm building a UI using the group constructor, here is the line code I'm using to load the image: myImg:Image{text:'',image:'(image_folder)/image.png', alignment:['lef

  • Forms not active in Communication tab in Customs Declaration

    Hi, The forms (Shippers Letter of Instructions, SED, COO etc) are not active and not showing up in "Communication" tab of Customs Declaration while creating a customs declaration manually from transaction /SAPSLL/CL_CUS_01. Appreciate any help in poi

  • Software development

    Im familiar with Unity 3D which is 3D game engine for pc, mac, android, iphone and ipad platforms. Last year Microsoft said that they are not going to support native code on WP7. This was before Nokia. Now when this new deal came public is Nokia goin

  • IMovieHD 5: Type Degradation

    I want to create slides for a movie and would like all slides to contain up to 8 lines of text that is all the same size. All of my options in 5.0.2 seem to be Titles will the top line in a larger face that the next lines down. I tried a workaround,

  • Change the sold to party

    Hi expert,                  Can i change " Sold to party code"  after the creation of the sales order. Regard Shashi