Khalid, I am not sure if I read your question right. Anonymous strings can exist without any references. For example, consider the statement System.out.println("Hello"+"World"); Here, two strings are created internally in the string pool, but they will have no way to refer to them again after the statement. Is this what you were asking? If not, please ask clearly. Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
In Marcus Green's applet exam he has a question: ---Number:47--- Which of the following is[sic] will sucessfully[sic] create an instance of the Vector class and add an element;[sic] 1) Vector v = new Vector(99); v=99; 2) Vector v= new Vector(); v.addElement(99); 3) Vector v=new Vector(); v.add(99); 4) Vector v = new Vector(100); v.addElement("99"); The answer given is 4 The addElement function takes Object as a parameter. So I'm assuming that all string literals "" are automatically 4(implicitly)paired with a String reference object. Otherwise shouldn't two and three be valid answers as well? Thanks again, Khalid [This message has been edited by Khalid Bou-Rabee (edited July 17, 2000).]
2 and 3 can't be right answers because : To a vector u can only add Objects - in "2" an int is being added which is not allowed. There is no add(int i) method for Vector class. You can add only using addElement() - in "3" the method being used is "add(int i)" you could use add(int i, Object o) or add(Object o). Ankur [This message has been edited by Ankur (edited July 17, 2000).]
recall: ---Java 2 Platform Specs:Vector Class--- <pre> addElement public void addElement(Object obj) Adds the specified component to the end of this vector, increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity. This method is identical in functionality to the add(Object) method (which is part of the List interface). Parameters: obj - the component to be added. See Also: add(Object), List </pre> [This message has been edited by Khalid Bou-Rabee (edited July 17, 2000).]