Two string references pointing to the same object

Look at the following code snippet         String   s1 = "hello";
        String   s2 = "world";
        String   s3 = "welcome";
        String   s4 = "here";
        String   s5 = "hello";
  They say that references s1 and s5 point to the same object "hello".
At run time after creating objects from s1 to s4 how the Java run time knows that there is already an object "hello" and assigns a differernt reference.

When the jvm load the class file, all suchconstants
found in the class are loaded in a global constant
pool. when you assign the constant to a variable,it
uses the same one from the constant pool.Suppose I intialize a string by getiing input
nput from the console which already exists, in that
case a new object will be created or the existing one
be used.A new object will always be created in that case, but you can get a reference to the string in the pool by calling intern. See the javadoc for intern in the String class.
Kaj

Similar Messages

  • Two selection option-variables for the same object

    Hi,
    I'm using two selection-option variables for the same characteristic in my query:
    One is authorization variable and the other is used for restrictions (filter) in a selection screen.
    I get an error: SELOPT/Query variable .... does not allow any further selections.
    If a selection option-variable is used, no additional selections can be specified for this characteristic in this element.
    Is there a way to overcome this problem?
    Thanks,
    Hagit

    Hi,
    I have solved the problem by changing the authorization object (in RSECADMIN) from range to single value and also the variable in BEx from selection single value.
    To be more clear:
    object in RSECADMIN was: infoobject BT var1 - var5
    I have changed it to:
    infoobject EQ var1
    infoobject EQ var2
    infoobject EQ var3
    infoobject EQ var4
    infoobject EQ var5
    Hope this helps.
    Hagit

  • Two QM servers point to the same UCCX Cluster

    All,
    We have a QM8.0 in production pointing to a UCCX 8.5/CUCM8.5. It does Audio recording only using network recording method and it has a SQL 2008 server installed locally.
    We are installing a second QM8.5 system after ordering extra AQM seat license. We use the second QM system for screen and audio recording (using desktop record). Instead of using locally installed SQL, we plan to use SQL 2008 Cluster at the backend SQL farm.
    Both QM systems point to the same UCCX/CUCM Cluster. The initial configuration of the second QM system was successful. SQMDB was created in SQL Cluster (the instance created for QM). QM could see all licenses (QM and AQM) loaded in UCCX system. However, using QM Administrator utility to configure users/teams, I cannot see any UCCX agents and teams. When do a synchronise, got error:
    QMAD2003: SyncServerError: SyncFailure: SyncFailed: com.calabrio.sync.engine.dataSyncException: Exception while getting DB connection (-1)
    Has anyone experience this type of problem? Is there a limit that one UCCX cluster could only have one QM system associated?
    Thanks,
    Wenqian

    This problem has been fixed. In QM log (sync.dbg), it clearly stated that the password for uccxworkforce was wrong. After changed it to the right password, all works well.
    I thought I could see the seat license from UCCX server indicating that I entered correct password in my initial configuration. It is not the case.
    Wenqian

  • Two feed IDs pointing to the same URL by accident.

    I think I have quite a conundrum here. I manage 2 podcasts, and one of them I had to change hosts. I used the <itunes: new-feed-url> tag which worked great. But unfortunately, I also added it to the second feed XML by accident, and now both feeds point to the same URL. So now if I change one, it will change both again. I contacted normal apple support, but they said its beyond them. I also went to our podcast page on the itunes store and "reported a concerne", but to no avail.
    Does anyone have an idea how to contact itunes techs and have them manually change the url of the mistaken feed?
    Thanks.

    Go to:
    http://www.apple.com/support/itunes/store/podcast/
    and use the 'Contact us' link at the bottom of the page. It does indeed sound as if you have got yourself into a Catch-22 that only they can get you out of.

  • Two id's point to the same feed

    Hi, we are from Italy, and maybe someone here can help:
    The facts:
    We have since 2005 an audio podcast and we obtained from iTunes an ID linked to this feed: http://www.feltrinellieditore.it/fs/podcast-xml/fpodcast.xml
    In 2007 we opened a second podcast (video) and we obtained from iTunes another ID and originally linked to this feed: http://www.feltrinellieditore.it/fs/podcast-xml/fpodcast_video.xml
    For unknown reasons the second podcast now points to the first xml feed (http://www.feltrinellieditore.it/fs/podcast-xml/fpodcast.xml). So the second one (the videopodcast) disappeared and if you check the two ID's you'll notice that you get 2 equal channels.
    Can anyone help? Our aim is to back-up the previous situation with 2 separated channels.
    We have just wrote to the support, hoping they will reply
    thanks

    Both of your feeds include an unnecessary 'itunes:new-feed-url' tag. This is used when you want to redirect iTunes to a different feed. In each case the tag contains the URL of the feed it is actually in and so it's completely redundant.
    The feed at http://www.feltrinellieditore.it/fs/podcast-xml/fpodcast_video.xml contains the tag
    <itunes:new-feed-url>http://www.feltrinellieditore.it/fs/podcast-xml/fpodcast_video.xml</itunes:new-feed-url>
    I suspect that at some stage, perhaps when you created it, it contained the URL of the first feed (perhaps you copied the original feed to use as a template - always a dodgy idea), and that by the time you had changed it iTunes had already switched that podcast ID to the first feed.
    (For reference, the two feeds' Store URLs are
    http://itunes.apple.com/gb/podcast/radio-feltrinelli/id84983267
    and
    http://itunes.apple.com/gb/podcast/radio-feltrinelli/id256773836 )
    You have now painted yourself into a corner. You can't use the 'itunes:new-feed-url' tag to redirect to the video feed, as it would affect both versions and you would be back where you started.
    You could ask the Store to change the feed in use for the second podcast ID: someone did manage to get them to change a feed when he couldn't access the feed to add the redirect, and you could try this, but I honestly don't hold out a lot of hope for this. iTunes support is at
    http://www.apple.com/support/itunes/ - click on 'Other iTunes Store Features' in the list and then on 'Podcasts'.
    Your only other method is to ask iTunes to remove the second podcast (256773836) altogether - the process is described here:
    http://www.apple.com/itunes/podcasts/specs.html#removing
    You would then resubmit the second feed and start all over again. And I should remove those 'itunes:new-feed-url' tags.

  • Two folders pointing to the same document

    Hi,
    can two KM folders point to the same document?
    for e.g.
    say I have two users 1) a business person 2) a technical person.
    I have two folder structures 1) a technical structure 2) a business structure with each having access to the all the folders structures.
    say tech folder structure has a folder called ep and business folder structure has a folder called client1. The technical person uploads a document of client1 project that is related to ep in the ep folder that is part of the technical strucure.
    How do I make it possible to access the document in both the folders(ep and client1)? I don't want redundant documents as it can cause the changes not to get reflected.

    Hi,
      You can do that using taxonomies. You upload the document, assign metadata and then by mean TREX index is classified.
      You create KM Navigation Iviews to point these taxonomies folders.
      You can read about taxonomies:  http://help.sap.com/saphelp_nw04s/helpdata/en/6c/5145b1d1de11d6b2cc00508b6b8b11/frameset.htm
    Patricio.

  • String objects with the same string pointing to the same place but?

    Hi,
    Here is a simple sample
    String str1 = "a";
    String str2 = "a";I understand that in Java str1 and str2 pointing to the same place in memory and Java compiler wouldn't save the string "a" in two different places in memory. Am I right?
    If so, if the value of str1 changes to something else as following:
    String str1 = "a";
    String str2 = "a";
    str1 = "b";why str2 which has been pointing to the same place as str1 before is still containing ?a? and not ?b????
    Thanks!

    Maria1990 wrote:
    Hi,
    Here is a simple sample
    String str1 = "a";
    String str2 = "a";I understand that in Java str1 and str2 pointing to the same place in memory and Java compiler wouldn't save the string "a" in two different places in memory. Am I right?Correct.
    Maria1990 wrote:
    If so, if the value of str1 changes to something else as following:
    String str1 = "a";
    String str2 = "a";
    str1 = "b";why str2 which has been pointing to the same place as str1 before is still containing ?a? and not ?b????Because str2 is pointing to the same "a", but it is not pointing to str1.
    This is what happens:
    String str1 = "a";
    /*                 +---+
             str1 ---->| a |
                       +---+
    String str2 = "a";
    /*                 +---+
             str1 --+->| a |
                    |  +---+
                    |
             str2 --+
    NOT:
                       +---+
         +-> str1 ---->| a |
         |             +---+
         |
         +- str2
    str1 = "b";
                       +---+
                 +---->| b |
                 |     +---+
                 |
                 |     +---+
            str1-+  +->| a |
                    |  +---+
                    |
             str2 --+
    */

  • Vector clone references the same objects??

    Hi all
    I'm developing a simple chess program.
    Obviously, each move the user tries must be checked against the following sets of chess rules:
    1.) Whether it is that colour player's turn to move
    2.) Whether this move is valid for this specific piece (eg. 3 forward for a King --> invalid of course)
    3.) Whether this move will jeopardize the player's king (put it in check)
    If from any of the above the move is found to be invalid, the move is not executed.
    My program structure is briefly this:
    A. abstract super class 'ChessPiece' - subclassed by the various specific Chess Piece classes.
    Each of the specific ChessPiece subclasses must implement an abstract method to check if a
    proposed move is valid, and also a method to actually do the move...
    B. 'PieceManager' class - has a Vector of ChessPieces:
    This class checks whether the given move is valid:
    For the piece: by calling the checking method (see A above)
    For the general game: by making sure the given move doesn't put the player's king in check.
    NOTE: In chess (for those who don't know), it is illegal to move any piece if, at the end of
    the move, your king will be in check [possible to be captured by any enemy piece]
    This last check I want to do in the following way:
    1) copy/clone the entire PieceManager object
    2) in this copied object, actually do the move
    3) still in the copied/cloned object, see if the moving player's king is now in check
    4) based on this evaluation, execute the move in the original PieceManger object or don't...
    The Problem:
    When I clone this PieceManager object, its 'pieces' Vector is obviously also cloned.
    BUT it seems that the cloned 'pieces' Vector references the same ChessPiece objects
    as those referenced by the original 'pieces' Vector; ie the 2 Vectors are sharing the same Objects.
    Thus, when I actually execute the move in the test/cloned PieceManager object,
    the original PieceManager's corresponding piece is moved too (well, it seems it is the same piece...).
    I am pretty stuck with this.
    I've tried the Vector clone method; it doesn't seem to copy the objects, but create another reference
    to the same objects, as I've said.
    I've tried cloning the entire object ; also not helping......
    I'd love any comments, helpful pointers, suggestions.
    Also any comments on my program structure... is a Vector the best tool for this job?
    Thanks very much -
    lutha

    Hi all, OP here.
    Ok thanks guys for all your posts...
    two points:
    1) I have tried the "copy constructor", and it seems to be doing the same thing. (ie 'shallow clone')
    What's really frustrating me is that nothing I do seems to actually physically copy the Vector's objects
    to new, separate copies of those objects...
    I had my PieceManager class implement Cloneable (just in case - not too sure on that one; in fact I
    commented that out later), and I overrode the clone method like this:
    public Object clone ()
            PieceManager pm = new PieceManager ();
            Vector pcs = new Vector ();
            // Enumeration e = pieces.elements ();
            //while (e.hasMoreElements ())
            //    ChessPiece p = (ChessPiece) e.nextElement ();
            //pcs.add ();
            //}  // still references the same objects!!
            pieces.trimToSize ();
            int size = pieces.size ();
            Object[] arr = new Object [size];
            Object[] initial = pieces.toArray ();
            System.arraycopy (initial, 0, arr, 0, size);
            for (int i = 0 ; i < size ; i++)
                ChessPiece p = (ChessPiece) arr ;
    pcs.add (p);
    pm.pieces = pcs;
    return pm;
    This all still does the same 'shallow cloning'...
    2) m.winter, my ChessPiece objects are not immutable - they have a co-ordinate field that
    changes as they are moved. This is for getting as called by another object, and for checking in
    the ChessPiece's own internal method for checking whether the passed-in square co-ordinate
    is a valid destination.
    Anyway, I don't think that's the main issue here. How can I properly clone/copy a Vector, resulting
    in :
    a) the original Vector
    b) a new, totally unrelated Vector.
    Thanks again all for your input.
    regards,
    lutha

  • Two Threads Sharing the Same Object

    I am learning Java multithreading recently and I really hit the wall when I came to synchronizing data using the synchronized keyword. According to the explanation, synchronized will only work when 2 or more threads are accessing the same object. If there are accessing 2 different objects, they can run the synchronized method in parallel.
    My question now is how to make sure for synchronized method to work, I am actually working with the same and only one object??
    Imagine this:
    Two person with the same account number are trying to access the very ONE account at the same time.
    I suppose the logic will be:
    Two different socket objects will be created. When it comes to the login or authentication class or method, how can I make sure in term of object that the login/authentication class or method will return them only ONE object (because they share the same account), so that they will be qualified for using the synchronized method further down the road?
    Thanks in advance!

    Actually your understanding is wrong. Consider:
    public class MyClass {
      private int someInt;
      private float someFloat;
      private synchronized void someMethod(final int value) {
        if (value > 2000) someInt = 2000;
      private synchronized void someOtherMethod(final float value) {
        if (value > 2.0) someFloat = 1.999f;
    }YOu might think that two different threads can enter this code, one can enter in someOtherMethod() while one is in someMethod(). That is wrong. The fact is that synchronization works by obtaining synchronization locks on a target object. In this case by putting it on the method declaration you are asking for the lock on the 'this' object. This means that only one of these methods may enter at a time. This code would be better written like so ...
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized(someInt) {
          if (value > 2000) someInt = 2000;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) someFloat = 1.999f;
    }In this manner you are only locking on the pertinent objects to the method and not on 'this'. This means that both methods can be entered simultaneously by two different threads. However watch out for one little problem.
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized(someInt) {
          if (value > 2000) {
            someInt = 2000;
            synchronized (someFloat) {
              someFloat = 0.0f;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) {
            someFloat = 1.99999f;
            synchronized (someInt) {
              someInt = 0;
    }In this case you can have a deadlock. If two threads enter one of these methods at the same time one would be waiting on the lock for someInt and the other on the lock for someFloat. Neither would proceed. The solution to the problem is simple. Acquire all locks in alphabetical order before you use the first.
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized (someFloat) {
          synchronized(someInt) {
            if (value > 2000) {
              someInt = 2000;
              someFloat = 0.0f;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) {
            someFloat = 1.99999f;
            synchronized (someInt) {
              someInt = 0;
    }In this manner one thread will block waiting on someFloat and there can be no deadlock.

  • Two different WCS instances, pointing to the same database

    Hi,
    for some unknown reason that came from the architecture fellows, I need to install 02 instances of WCS pointing to the same database server. I mean, both instances would need to "share" the database. They don't want a cluster schema because they need to have the option to deploy the app in one instance and, if wverything is ok, deploy to the remaining instance.
    Do you know if such architecture is possible? I did the installation of one instance(instance A), but when trying to install the instance B referring to A's database, I get a ton of errors.
    Any advice is much appreciated.
    Regards,
    Vinicius
    Edited by: 1000164 on Apr 15, 2013 8:18 PM

    Hi,
    This is not the way Sites has been designed. Each instance should have their own schema and repository unless the two instances work as a Sites cluster.
    So what you're trying to achieve is not possible using your approach. What I could suggest is to install two separate instances on its own, create the necessary data model, asset configurations, templates, etc. in one instance and replicate it to the other instance by publishing it to the other instance using real-time publish. If you use LDAP or any other supported directory server you would be able to use a singe directory for both sites instances.
    Regards,
    Rodney

  • Two 9IAS pointing to the same orgin database !!

    Hello Guys,
    I need to setup such way that
    two 9IAS machines will be pointing to
    the same origin machine (i.e third m/c) !!!
    By doubt is what are products we need to install in the second machine !!!
    Let us say in the first machine, I install the following products
    Oracle9ias database cache
    oracle 9ias forms and reports services
    oracle http server in non-ssl mode
    oracle 9ias web cache
    oracle 9ias portal
    oracle 9ias discoverer
    oracle management server
    Let me guess, what should be install in second machine
    Oracle9ias database cache - yes
    oracle 9ias forms and reports services - yes
    oracle http server in non-ssl mode - yes
    oracle 9ias web cache - yes
    oracle 9ias portal - no
    oracle 9ias discoverer - yes
    oracle management server - yes
    Please let me know whether my jugement is right or not !!!
    I am only scared whether the original products(i.e first machine) will
    get updated !!!
    Thanks for your time !!!
    A.Kishore
    null

    kishore, I don't see any problem installing iAS on two different machines, if that's what you mean. Whatever you install on the 'second' machine will not affect the first. Since they have the different oraInventory location.

  • Adjusting two handles of an anchor point at the same time?

    Hi,
    Is it possible to adjust two handles of an anchor point at the same time?
    I want to edit the top shape of this egg shape so that it would be symmetrical on both sides when I do adjust it.
    What is the easiest way to accomplish this?
    Thanks!

    When I move the right handle, I need the left handle to move the opposite way and it doesn't. I don't get what you mean by saying that it "should behave just like you want them already."

  • Two iPhoto Library Names Point to the Same Path

    I'm not sure how this happened, but I now have two libraries that point to the exact same path.  One is uppercase and the other is normal.  See pic:
    How can I get rid of the uppercase library?

    Try trash the com.apple.iPhoto.plist file from the HD/Users/ Your Name / library / preferences folder.
    (On 10.7: Hold the option (or alt) key while clicking on the Go menu in Finder to access the User Library)
    (Remember you'll need to reset your User options afterwards. These include minor settings like the window colour and so on. Note: If you've moved your library you'll need to point iPhoto at it again.)
    What's the plist file?
    For new users: Every application on your Mac has an accompanying plist file. It records certain User choices. For instance, in your favourite Word Processor it remembers your choice of Default Font, on your Web Browser is remembers things like your choice of Home Page. It even recalls what windows you had open last if your app allows you to pick up from where you left off last. The iPhoto plist file remembers things like the location of the Library, your choice of background colour, whether you are running a Referenced or Managed Library, what preferences you have for autosplitting events and so on. Trashing the plist file forces the app to generate a new one on the next launch, and this restores things to the Factory Defaults. Hence, if you've changed any of these things you'll need to reset them. If you haven't, then no bother. Trashing the plist file is Mac troubleshooting 101.

  • Can two datasources point to the same database?

    Can two unique datasource names point to the same MS Access Database?

    I got handed a directory of files to set up two coldfusion sites on a new server. What I have is two websites which both have a gallery page with identical contents, see Jembetat.com and SaharaAfricanGallery.com. In the the files I got in the Jembetat directory I have a single database "jembetat.mdb", in SahraAfricanGallery directory I have two databases "jembet.mdb" and "sahara.mdb" The Jembetat site refers to a dsn titled "Jembetat_accesscf_jembetat" pointing to the "jembetat.mdb"  and the sahara site to a dsn titled "sahara20049216_accesscf_jembetat". Interestingly enough I believe all three databases are identical. Currently I am pointing the jembetat dsn to the jembetat database in the sahara directory and the sahara dsn to the sahara database in the sahara directory. In my mind however if the client makes a change on one website then he would have to manually change it on the other unless I point poth dsn to the same directory.

  • Rotate an image after clicking two times on reference points on the picture

    Hello Community!
    I am looking for a solution to rotate an image by clicking on two reference points on the image. The two coordinate pairs of the mouse clicking can give me the rotation angle with simple geometry. After that I will rotate the image with the calculated angle.
    My problem is: How can I get those two coordinate pairs? I wanted to do it with an easy MatlabScript "input: path ... imread(path) ... imshow ... ginput(2) ... calculation ...output: angle". Apparently imshow doesnt work in Labview
    I already have the Mouse Down event but I dont know how I can make Labview let me click EXACTLY and ONLY two times on my picture and store the coordinates.
    Does anyone of you have a glue/ hint how to do that? 
    Best,
    Annki
    (Started LabView 2 weeks ago)
    Solved!
    Go to Solution.

    Hi Annkitranky,
    welcome to the forum!
    Here is one that works well: http://en.wikipedia.org/wiki/Cyanoacrylate  (Sorry, I couldn't resist...)
    Check this out: http://forums.ni.com/t5/LabVIEW/Using-mouse-click-to-return-image-coordinates/m-p/890731 and http://forums.ni.com/t5/LabVIEW/How-to-find-cursor-position-on-an-image-in-LabVIEW/m-p/1862495 There is a suggestion not marked as a solution, but I think it is: see last posts there; User Event Structure with the position reported implicitly. Further, I would put the Event Structure in the While Loop, where I wait for user input, collect the user inputs and finish (execute rotation on a two-element array).
    If you have a code or something, post it.
    Cheers

Maybe you are looking for

  • I have typed many documents to pages and saved as a folder i have just looked in the folder and everything has gone help

    i have typed many documents on pages and saved to a new folder i created i have just opened it half hour ago and saved some more and all ok i just reopened to save another and all the documents have gone help how do i get them back and where they go

  • Parse multiple files in one flat file?

    Hi all, I'm currently working with flat file with  this kind of structure: "849000","1","2","3","4"             <- begin of file "849HD","","1939","12"              <- header level "849D1","39193","313","1"         <- detail level "849D2","","descrip

  • Remove IE9 and reinstall IE8 on Windows 7

    Hi Guys, We have an issue were we have some Windows 7 running on it. We need to access an old System that doesn't support IE9 or any other bowser except IE8, IE7 or even IE6. Is there a way to uninstall IE9 or even install IE8 Along side IE9?

  • AR credit check

    Hello, Can someone tell me how do we do credit check at sales order in credit management. Is this credit check at sales order level same in both AR credit mgmt and FSCM credit mgmt? Definite points............. Regards, Sriram

  • CLEAN_REQREQ_UP results in "Buffer Table not up to date"

    Dear all, we are getting an error while running CLEAN_REQREQ_UP (SRM 5.00 / SAPKIBKT11). Without any selection, the report runs into a "Buffer Table not up to date" error. All scheduled jobs also get aborted. Tried to reset the buffers using $sync. D