Why String Objects are immutable ?

From the JLS->
A String object is immutable, that is, its contents never change, while an array of char has mutable elements. The method toCharArray in class String returns an array of characters containing the same character sequence as a String. The class StringBuffer implements useful methods on mutable arrays of characters.
Why are String objects immutable ?

I find these answers quite satisfying ...
Here's a concrete example: part of that safety is ensuring that an Applet can contact the server it was downloaded from (to download images, data files, etc) and not other machines (so that once you've downloaded it to your browser behind a firewall, it can't connect to your company's internal database server and suck out all your financial records.) Imagine that Strings are mutable. A rogue applet might ask for a connection to "evilserver.com", passing that server name in a String object. The JVM could check that this server name was OK, and get ready to connect to it. The applet, in another thread, could now change the contents of that String object to "databaseserver.yourcompany.com" at just the right moment; the JVM would then return a connection to the database!
You can think of hundreds of scenarios just like that if Strings are mutable; if they're immutable, all the problems go away. Immutable Strings also result in a substantial performance improvement (no copying Strings, ever!) and memory savings (can reuse them whenever you want.)
So immutable Strings are a good thing.
The main reason why String made immutable was security. Look at this example: We have a file open method with login check. We pass a String to this method to process authentication which is necessary before the call will be passed to OS. If String was mutable it was possible somehow to modify its content after the authentication check before OS gets request from program then it is possible to request any file. So if you have a right to open text file in user directory but then on the fly when somehow you manage to change the file name you can request to open "passwd" file or any other. Then a file can be modified and it will be possible to login directly to OS.
JVM internally maintains the "String Pool". To achive the memory efficiency, JVM will refer the String object from pool. It will not create the new String objects. So, whenever you create a new string literal, JVM will check in the pool whether it already exists or not. If already present in the pool, just give the reference to the same object or create the new object in the pool. There will be many references point to the same String objects, if someone changes the value, it will affect all the references. So, sun decided to make it immutable.

Similar Messages

  • 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."

  • String object are constant

    what does this mean?
    when I declare and define the following:
    String s1 = "test";
    does this mean that s1's value "test" will never be changed in the course of the program?
    thanks.

    examine this code:public class Immutable {
            public static void main(String[] args) {
                    String s1 = "original String ";
                    String s2 = s1;
                    StringBuffer sb1 = new StringBuffer(s1);
                    StringBuffer sb2 = sb1;
                    s1 = "changed String ";
                    sb1.append(s1);
                    System.out.println(s1);
                    System.out.println(s2);
                    System.out.println(sb1);
                    System.out.println(sb2);
    }and it will print:
    changed String
    original String
    original String changed String
    original String changed String
    as you see, s2 got evaluated with value of s1, then later s1 got new value, but the value that it had, didn'd change, so s2 stays the same.
    now sb1 got evaluated with original value of s1, and later had appended the new value of s1, but sb2 got evaluated befor that appending took place, so if StringBuffer was immutable, then sb2 would be same as s2, but since sb2 points to the same object where to sb1, then it's value is changed as well when sb1 is changed
    if i would create new object for sb1 with new keyword, then sb2 would end up pointing to original sb1, but sb1 would point to new object so i could change these independently...
    HTH

  • String object vs String literal

    Hi ,
    I understand how the string objects are created using new operator and using literal.I also understand how they are stored in memory.All I want to know is that when and why should I create a String object using new and when I should create an object using literal.Is there any specific reason for creating an object using new operator when objects created by both the ways are immutable.
    Thanks for the help in advance.
    Thanks
    Mouli

    If you look at the String source code (particularly the constructors) youll learn a lot.
    String objects contain a char[] array - and this is the most important part --> a start and length value.
    I believe they were attempting to optimize, but this has important implications for developers.
    String objects dont necessarily store just the text you see, it may just reference a much bigger char array.
    For example, say an API passes you a string that is (lets pretend) a file path (C:\files\java\...\file.txt) that is 1,000,000 characters long.
    Now say that you call getFileName() and want to save the filename in a list.
    String filename = API.getFile("...").getFileName();
    List.add(filename);
    Say you do this about 250,000 times.
    You estimate that the average file name is 10 chars and ensure there is that much RAM.
    You run out of memory. Why?
    Well, this example actually happened to me in a real program I was writing to archive drive files.
    File.getFilename() returns a substring() of the entire File path.
    However, substring is implemented to return a String that just references the original char[] array!
    So the really long file path never gets garbage collected!
    I was able to fix the program by coding it:
    String filename = new String(API.getFile("...").getFileName()); // Copies only the needed chars!
    List.add(filename);
    So thats really all you need to watch out for. If memory is a concern in your program you want to
    make sure you arent referencing large char[] arrays unnecessarily.
    But like all things, this is rarely anything to give much thought to.
    Only something to remember if you run into problems after coding sensibly and profiling
    (or in my case, crashing with OOM exceptions, lol).

  • String Object info not getting displayed in outgoing referrences .

    Hi,
    Iam new to MAT and is in learning stage.
    Iam having a sample java program , whch has got String objects printed contunously . In order to take the heap dump while running itself , I am running this application for 2 minutes and in between Im taking the heap dump , but when analysed my java class , found that there is no entry for String objects under outgoing referrences of the java class from histogram.
    Please help me to find out why String object details are not present in outgoiing referrences for the java class.
    My Java Program,
    public class B{
    public static void main(String[] args) {
              //create Calendar instance
             Calendar now = Calendar.getInstance();
             System.out.println("Current time : "+ now.get(Calendar.HOUR_OF_DAY)+ ":" + now.get(Calendar.MINUTE)+ ":"+ now.get(Calendar.SECOND));
             int m = now.get(Calendar.MINUTE);
             B b = new B();
             b.print();
    public void print( int m2, Calendar now2){
               while ( (m2+2) >= now2.get(Calendar.MINUTE)){
                       String x = "xxxxxx";
                        System.out.println("String"+x);

    Hi,
    Do you mean this String object?
       String x = "xxxxxx";
    If so, then here the explanation. The String above is declared as a loca variable in the print method. I can't see any field pointing to it (neider an object insance is pointing to it, nor a static reference from the class).
    This local object will be in the heap as long as the method is running, and in the heap dump you will see such objects marked as GC roots. The type of this GC root will be <Java local> .
    Depending on the heap dump format, there may be also stack traces inside. If there are stack traces, you shold be able to see your object as referenced from the corresponding frame (the print method) in the Thread Stacks query.
    I hope this helps.
    Krum

  • "a"+"b"+"c", how many String objects created?

    Hello everyone,
    String s = "a" + "b" +"c";
    How many String objects are created?
    I guess 5, is it right?
    regards

    > How many String objects are created?
    >
    I guess 5, is it right?
    Nope. Just one.

  • String Object  VERY  Urgent

    I have code
    String s1="5+5=10";
    s1.trim();
    s1.replace('+','-');
    then how many String Objects are created.

    For that matter, how do you make a moot do anything?A "moot" is a collection of lawyers gathered together
    to discuss a hypothetical point. So how do you get a
    collection of lawyers to do anything? A court order
    might work.
    PC�That would get them to do something, but whether it would be what you actually wanted them to do is another matter. :-)

  • Why jvm maintains string pool only for string objects why not for other objects?

    why jvm maintains string pool only for string objects why not for other objects? why there is no pool for other objects? what is the specialty of string?

    rp0428 wrote:
    You might be aware of the fact that String is an immutable object, which means string object once created cannot be manipulated or modified. If we are going for such operation then we will be creating a new string out of that operation.
    It's a JVM design-time decision or rather better memory management. In programming it's quite a common case that we will define string with same values multiple times and having a pool to hold these data will be much efficient. Multiple references from program point/ refer to same object/ value.
    Please refer these links
    What is Java String Pool? | JournalDev
    Why String is Immutable in Java ? | Javalobby
    Sorry but you are spreading FALSE information. Also, that first article is WRONG - just as OP was wrong.
    This is NO SUCH THING as a 'string pool' in Java. There is a CONSTANT pool and that pool can include STRING CONSTANTS.
    It has NOTHING to do with immutability - it has to do with CONSTANTS.
    Just because a string is immutable does NOT mean it is a CONSTANT. And just because two strings have the exact same sequence of characters does NOT mean they use values from the constant pool.
    On the other hand class String offers the .intern() method to ensure that there is only one instance of class String for a certain sequence of characters, and the JVM calls it implicitly for literal strings and compile time string concatination results.
    Chapter 3. Lexical Structure
    In that sense the OPs question is valid, although the OP uses wrong wording.
    And the question is: what makes class Strings special so that it offers interning while other basic types don't.
    I don't know the answer.
    But in my opinion this is because of the hybrid nature of strings.
    In Java we have primitive types (int, float, double...) and Object types (Integer, Float, Double).
    The primitive types are consessons to C developers. Without primitive types you could not write simple equiations or comparisons (a = 2+3; if (a==5) ...). [autoboxing has not been there from the beginning...]
    The String class is different, almost something of both. You create String literals as you do with primitives (String a = "aString") and you can concatinate strings with the '+' operator. Nevertheless each string is an object.
    It should be common knowledge that strings should not be compared with '==' but because of the interning functionality this works surprisingly often.
    Since strings are so easy to create and each string is an object the lack ot the interning functionality would cause heavy memory consumption. Just look at your code how often you use the same string literal within your program.
    The memory problem is less important for other object types. Either because you create less equal objects of them or the benefit of pointing to the same object is less (eg. because the memory foot print of the individual objects is almost the same as the memory footpint of the references to it needed anyway).
    These are my personal thoughts.
    Hope this helps.
    bye
    TPD

  • Why should I wrap String objects in a class for my HtmlDataTable?

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

  • Why create a String object no need to use constructor?

    If we create a Java String object, we will do:
    String s = "Hello";
    And we won't do:
    String s = new String("Hello");
    In API doc, String() constructor description says "Initializes a newly created String object so that it represents an empty character sequence. Note that use of this constructor is unnecessary since Strings are immutable."
    I am not sure how immutable is related to this??
    Also, I wonder if the compiler will convert
    String s = "Hello" to
    String s = new String("Hello");
    Thanks!

    String s = new String("Hello");
    This is a valid statement too..... But the compiler will not convert String s = "Hello" to String s = new String("Hello") as you suggested. The reason is that java has a sort of a String Bag. Everytime you do a String s = "Hello" it will check the bag and see if such a string already exists. If it does, it merely creates a pointer to it, because strings are immutable, it doesn't need to worry about others modifying that string. If the string doesn't exist then it creates the necessary memory for the string object and adds the reference to the bag.
    However, once you do a String s = new String("Hello") what you are saying to the compiler is, "Hey, don't check the bag just create the String." This is all fine and dandy, except that it increases the memory size of your program unnecessarily.
    V

  • Strings are immutable

    I want to know what exactly it means when u say that Strings r immutable.I need to understand with ex.please.There r StringBuffers to handle it we say.
    We can concatenate a string with another too. SO what is immutable means?
    CAn anyone help?Thanks in advance.

    Immutable means that the object can not be modified after it is constructed. For Strings, there are no methods that allow the value of the String to be changed. Thus, for a every new value, a new String object must be created. StringBuffers on the other hand, have methods like append and setCharAt that allows the value stored to be changed. You can create one StringBuffer object and keep altering it.
    Concatenation does not actually modify a String. It creates a new one. Notice how you have to assign the concatenated value to something.
    String str1;
    str1 = "test ";
    str1 + "string";
    System.out.println(str1);  // concatenation didn't modify str1
    str1 = str1 + "string";  // assign a new string which is the concatenation of str1 and "string" to str1
    System.out.println(str1);  // str1 refers to a completely new String, the concatenation
    StringBuffer sb1;
    sb1 = new StringBuffer("test ");
    sb1.append("string");
    System.out.println(sb1);  // sb1 was modified
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Where is String object in memory? and why?

    I read an article about String, it states:
    String str1 = new String("abc");
    the String object in the heap,
    String str2 = "abc";
    then String object will be in data segment?
    is the statement true? and why? it's a really interesting question, thx

    Thanks you so much for the great article!!
    cotton.m!!
    I can cheat on my assignment again, haha!
    strange
    Stepwise Refinement :|
    http://forum.java.sun.com//thread.jspa?threadID=5206258

  • Why objects are invalid?

    Hi all,
    IS there any specificreasons why there are so many objects are invalid....
    [per]
    SQL>
    SQL> select A.Owner Oown,
    2 A.Object_Name Oname,
    3 A.Object_Type Otype,
    4 'Miss Pkg Body' Prob
    5 from DBA_OBJECTS A
    6 where A.Object_Type = 'PACKAGE'
    7 and A.Owner ='data'
    8 and not exists
    9 (select 'x'
    10 from DBA_OBJECTS B
    11 where B.Object_Name = A.Object_Name
    12 and B.Owner = A.Owner
    13 and B.Object_Type = 'PACKAGE BODY')
    14 union
    15 select Owner Oown,
    16 Object_Name Oname,
    17 Object_Type Otype,
    18 'Invalid Obj' Prob
    19 from DBA_OBJECTS
    20 where Object_Type in
    21 ('PROCEDURE','PACKAGE','FUNCTION','TRIGGER','PACKAGE BODY','VIEW')
    22 and Owner ='data'
    23 and Status != 'VALID'
    24 order by 1,4,3,2
    25 /
    data
    CHK_CURR_CORR_REG_ART_CO_DEEP
    FUNCTION Invalid Obj
    data
    FN_CHK_MAIN_ACT
    FUNCTION Invalid Obj
    data
    F_GET_FC_OPBAL
    FUNCTION Invalid Obj
    data
    F_GET_LC_OPBAL
    FUNCTION Invalid Obj
    data
    F_GET_MAIN_FC_OPBAL
    FUNCTION Invalid Obj
    data
    F_GET_MAIN_LC_OPBAL_DIV_1
    FUNCTION Invalid Obj
    data
    F_GET_MAIN_LC_OPBAL_DIV_DEPT
    FUNCTION Invalid Obj
    data
    F_GET_SUB_FC_OPBAL
    FUNCTION Invalid Obj
    data
    F_GET_SUB_LC_OPBAL
    FUNCTION Invalid Obj
    data
    ODB_CHK_COMB_FIRM
    FUNCTION Invalid Obj
    data
    O_DGET_JOB_AUTO_CSV_STS_AUTO
    FUNCTION Invalid Obj
    data
    O_DGET_JOB_CSV_STATUS
    FUNCTION Invalid Obj
    data
    O_GET_SRN_APPL_DT
    FUNCTION Invalid Obj
    data
    O_GET_SRN_CCT_REG_DT
    FUNCTION Invalid Obj
    data
    O_GET_SRN_NAME1
    FUNCTION Invalid Obj
    data
    O_GET_SRN_PAID_FEES
    FUNCTION Invalid Obj
    data
    REM_TEST
    FUNCTION Invalid Obj
    data
    SAR_TEST_FUNC
    FUNCTION Invalid Obj
    data
    CUSTOMER_UPDATE
    PACKAGE Invalid Obj
    data
    OVERLOAD_EG
    PACKAGE Invalid Obj
    data
    PACK1
    PACKAGE Invalid Obj
    data
    PDM_STUD_REFUND_PECS
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REFUND_TCS
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_CCT
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_FND
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_INT
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_INT_DUMMY
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_INT_DUP_FND_NO
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_PE2ART
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_PE2ART_RAGHU
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_PEI
    PROCEDURE Invalid Obj
    data
    PDM_STUD_REG_PEII
    PROCEDURE Invalid Obj
    data
    ODBTRG101_ITEM
    TRIGGER Invalid Obj
    data
    ODBTRG103_REF
    TRIGGER Invalid Obj
    data
    ODBTRG437_AAT_ACVT_UPT_DAK
    TRIGGER Invalid Obj
    data
    ODBTRG437_AFCD
    TRIGGER Invalid Obj
    data
    ODBTRG437_AFCD_01
    TRIGGER Invalid Obj
    data
    ODBTRG437_AR
    TRIGGER Invalid Obj
    data
    ODBTRG437_BIN
    TRIGGER Invalid Obj
    data
    OV_MEM_FEE_CHK
    VIEW Invalid Obj
    data
    A_DUMMY
    PACKAGE Miss Pkg Body
    data
    CUSTOMER_UPDATE
    PACKAGE Miss Pkg Body
    data
    DBMS_LOCK
    PACKAGE Miss Pkg Body
    data
    ORNDBPKG_ART_FEE_COLL
    PACKAGE Miss Pkg Body
    data
    OVERLOAD_EG
    PACKAGE Miss Pkg Body
    data
    PACK1
    PACKAGE Miss Pkg Body
    data
    PKS
    PACKAGE Miss Pkg Body
    data
    RECEIPT_NO_VARIABLE
    PACKAGE Miss Pkg Body
    data
    STAGE_PACK
    PACKAGE Miss Pkg Body
    SQL> spool off

    SET SERVEROUTPUT ON;
    SET LINESIZE 1000;
    DECLARE
         || Cursor to all Object types in All_Objects belonging to the current user.
         CURSOR Cur_Object_Types
         IS
         SELECT DISTINCT Object_Type
           FROM All_Objects
          WHERE Owner = User;
         || Select the Invalid objects for the given object type.
         CURSOR Cur_Invalid_Objects(
              p_Object_Type     IN All_Objects.Object_Type%TYPE
         IS
         SELECT Object_Name, Status      
           FROM All_Objects
          WHERE Object_Type = p_Object_Type
            AND Status <> 'VALID'
            AND Owner = User;
         || Cursor to select the status of function based indexes.
         CURSOR Cur_FuncIdx
         IS
         SELECT Index_Name, FuncIdx_Status
           FROM User_Indexes
          WHERE FuncIdx_Status <> 'ENABLED';
         || Select all public synonyms created for current user object for
         || which underlying objects does not exists.
         CURSOR Cur_Synonyms
         IS
         SELECT Synonym_Name
               FROM All_Synonyms
          WHERE Owner = 'PUBLIC'
            AND Table_Owner = User
            AND Synonym_Name NOT IN (SELECT Object_Name
                                 FROM User_Objects);
         ln_LoopCnt     NUMBER;
         ln_TabIdxCnt     NUMBER;
         lv_Object_Type     VARCHAR2(100);
         lv_Object_Name     VARCHAR2(100);
         lv_Status     VARCHAR2(100);
         TYPE IObj_Type
         IS
         RECORD (Object_Type     VARCHAR2(100)
                ,Object_Name     VARCHAR2(100)
                ,Status          VARCHAR2(100)
         TYPE IObj_Tab_Type
         IS
         TABLE OF IObj_Type;
         IObj_Table      IObj_Tab_Type;
    BEGIN
         DBMS_OUTPUT.DISABLE;
         DBMS_OUTPUT.ENABLE(999999999999);
         DBMS_OUTPUT.PUT_LINE(CHR(10));
         IObj_Table   := IObj_Tab_Type();
         ln_TabIdxCnt := 0;
         FOR I IN Cur_Object_Types
         LOOP
                ln_LoopCnt := 0;
              FOR J IN Cur_Invalid_Objects(I.Object_Type)
              LOOP
                   ln_TabIdxCnt := ln_TabIdxCnt + 1;
                   ln_LoopCnt   := ln_LoopCnt + 1;          
                   IObj_Table.Extend;
                   IObj_Table(ln_TabIdxCnt).Object_Type := I.Object_Type;
                   IObj_Table(ln_TabIdxCnt).Object_Name := J.Object_Name;
                   IObj_Table(ln_TabIdxCnt).Status      := J.Status;
              END LOOP;
         IF ln_LoopCnt = 0 THEN
              ln_TabIdxCnt := ln_TabIdxCnt + 1;
              IObj_Table.Extend;
              IObj_Table(ln_TabIdxCnt).Object_Type := I.Object_Type;
              IObj_Table(ln_TabIdxCnt).Object_Name := ' ';
              IObj_Table(ln_TabIdxCnt).Status      := 'NONE';
         END IF;
         END LOOP;
         ln_LoopCnt := 0;
         FOR K IN Cur_FuncIdx
         LOOP
              ln_TabIdxCnt := ln_TabIdxCnt + 1;
              ln_LoopCnt   := ln_LoopCnt + 1;          
              IObj_Table.Extend;
              IObj_Table(ln_TabIdxCnt).Object_Type := 'FUNCTION BASED INDEX';
              IObj_Table(ln_TabIdxCnt).Object_Name := K.Index_Name;
              IObj_Table(ln_TabIdxCnt).Status      := K.FuncIdx_Status;
         END LOOP;
         IF ln_LoopCnt = 0 THEN
              ln_TabIdxCnt := ln_TabIdxCnt + 1;
              IObj_Table.Extend;
              IObj_Table(ln_TabIdxCnt).Object_Type := 'FUNCTION BASED INDEX';
              IObj_Table(ln_TabIdxCnt).Object_Name := ' ';
              IObj_Table(ln_TabIdxCnt).Status      := 'NONE';
         END IF;     
         ln_LoopCnt := 0;
         FOR L IN Cur_Synonyms
         LOOP
              ln_TabIdxCnt := ln_TabIdxCnt + 1;
              ln_LoopCnt   := ln_LoopCnt + 1;          
              IObj_Table.Extend;
              IObj_Table(ln_TabIdxCnt).Object_Type := 'PUBLIC SYNONYM WITHOUT UNDELYING OBJECT IN SCHEMA '||USER;
              IObj_Table(ln_TabIdxCnt).Object_Name := L.Synonym_Name;
              IObj_Table(ln_TabIdxCnt).Status      := 'UNDERLYING OBJECT NOT FOUND';
         END LOOP;
         IF ln_LoopCnt = 0 THEN
              ln_TabIdxCnt := ln_TabIdxCnt + 1;
              IObj_Table.Extend;
              IObj_Table(ln_TabIdxCnt).Object_Type := 'PUBLIC SYNONYM WITHOUT UNDELYING OBJECT IN SCHEMA '||USER;
              IObj_Table(ln_TabIdxCnt).Object_Name := ' ';
              IObj_Table(ln_TabIdxCnt).Status      := 'NONE';
         END IF;          
         IF IObj_Table.COUNT > 0 THEN
              FOR I IN 1..IObj_Table.COUNT
              LOOP
              lv_Object_Type     := IObj_Table(I).Object_Type;     
              lv_Object_Name     := IObj_Table(I).Object_Name;     
              lv_Status     := IObj_Table(I).Status;
                   IF I = 1 THEN
                        DBMS_OUTPUT.PUT_LINE('+-----------------------------------------------------------------------------------------------------------------------------+');
                        DBMS_OUTPUT.PUT_LINE(RPAD('|                                               LIST OF INVALID OBJECTS',134,' ')||'|');
                        DBMS_OUTPUT.PUT_LINE('|-----------------------------------------------------------------------------------------------------------------------------|');
                        DBMS_OUTPUT.PUT_LINE(RPAD('|                   OBJECT TYPE                              |               OBJECT NAME        |               STATUS',134,' ')||'|');
                        DBMS_OUTPUT.PUT_LINE('|-----------------------------------------------------------------------------------------------------------------------------|');
                   END IF;
                   DBMS_OUTPUT.PUT_LINE('| '||RPAD(lv_Object_Type,59,' ')||'| '||RPAD(lv_Object_Name,32,' ')||' | '||RPAD(lv_Status,28,' ')||'|');
              END LOOP;
              DBMS_OUTPUT.PUT_LINE('|-----------------------------------------------------------------------------------------------------------------------------|');
         ELSE
              DBMS_OUTPUT.PUT_LINE('THERE ARE NO INVALID OBJECTS IN SCHEMA '||USER||'.');
         END IF;
         DBMS_OUTPUT.PUT_LINE(RPAD('| NOTE: ',134,' ')||'|');
         DBMS_OUTPUT.PUT_LINE(RPAD('|      If you find any object in status INVALID / DISABLED / UNDERLYING OBJECT NOT FOUND, then ',134,' ')||'|');
         DBMS_OUTPUT.PUT_LINE(RPAD('|      execute the procedure RECOMPILE_INVALID_OBJECTS to fix the same.',134,' ')||'|');
         DBMS_OUTPUT.PUT_LINE('+-----------------------------------------------------------------------------------------------------------------------------+');
    END;
    [\pre]
    HTH..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Why r we allowed to create String objects with & without using new operator

    While creating any object, usage of the new operator is a must...but only for the string object we can create it with and also without new operator how is it possible to create an object without using new operator.

    Because Mr. (Dr.?) Gosling is a kindly soul who realizes that programmers have deadlines and, when he designed Java, was not so rigid or unbending as not to realize that from time to time, certain shortcuts are warranted, even in a relatively pure language such as Java. The direct String literal assignments are a shortcut over using the new operator making Java programming (and execution; there's also a performance benefit) more streamlined.
    So look not the gift horse in the mouth, but simply bask in the simplification and ease on the eyes and directly assign your little literals to your heart's content.

  • Why objects are  dynamically created in java

    Why objects are dynamically created in java even if dynamically created object requires more space & more memory references as compared to static object?

    I don't even know where to start...
    KAMAL.MUKI wrote:
    Why objects are dynamically created in javaWhat is the alternative?
    even if dynamically created object requires more space & more memory referencesCan you prove that?
    as compared to static object?Can you define "static object"?
    I vote "troll".

Maybe you are looking for

  • How to get mail accounts in all profiles?

    Hi, I setup 4 users in my imac, one for each family member. I setup the email accounts under my profile and when my wife logs in, the mail prog wants her to go thru the same process again. How do I copy the mail accounts from under my profile to all

  • How do I keep browser from re-sizing (zooming) flash video?

    Hi, Some browsers (Opera, Explorer, Firefox 3) can zoom entire pages, including text, images, and video. My flash videos have text that degrades (pixelates) badly under these circumstances. How can I embed a flash video in DW CS3 to keep the video di

  • CS5: ProRes 4444 Alpha issue rears it head again in a strange way

    So here's a strange one: I've found that if the first frame of a composition is completely opaque (such as using a solid to fade from black) then any QT Movie rendered with ProRes 4444 + Alpha will not include an alpha channel. I've replicated it on

  • How generate class histogram before/after GC (JVM 1.6.0.17 only JRE instal)

    Hi - looking for suggestions on how can generate a class histogram before a stop-the-world GC when using a Solaris 10 Sparc platform with java version 1.6.0.17 with only the JRE installed. I know about -XX:+HeapDumpBeforeFullGC/-XX:+HeapDumpAfterFull

  • Missing Episode in Series VOD Content Again

    A previous poster had requested that Verizon offer the expanded Starz HD VOD.  I would also like Verizon to expand their HD VOD premium selections (Starz HD on demand, SHO, etc).    They often skip key programming that is on Comcast HD VOD in my area