Difference between Mutable & Immutable objects

string is immutable what does actually it means...
though i have read some docs on net...
i could not gained complete understanding

Mutable objects are able to be changed like an integer
value for example:
i = 5;
i++; // I will now be equal to 6Only objects can be mutable/immutable, references to objects and primitive variables are not objects and
the value itself cannot be changed, only the contents of the variable itself can be changed.
Example
String a = "123";
String b = "456";
//** Both a and b refer to 2 different Strings
String c = b;
//** c now refers to the "456"
b = a;
//** b now points to "123" and has the same reference as a
//** Note, no changes to the actual objects themselves have been made so (im)mutability is not relevant
//** For primitives
int d = 1;
int e = 2;
//** e and d have different values, they "refer" to the integer constants 1 and 2 if you like
int f = e;
//** f has the same value as e, f and e refer to the integer constant 2
f++;
//** f has been incremented, it now "refers" to the integer constant 3, changing its value has not changed the value of eThis is important because Java passes things around by value not by reference.
When you have an object reference as a method parameter, the actual value of the parameter passed to
the method is the reference itself. This value you cannot change.
If Java were pass by reference then you could be able to actually change the value of that reference which means you
could end up pointing to a different part of the heap.
Example
int a = 5;
StringBuffer buff = new StringBuffer();
String b = "123";
//** primitive, mutable and immutable
//** call some method that takes these as parameters
System.out.println( someMethod( a, buff, b ) );
System.out.println( a );
//** the method has the following code
public StringBuffer someMethod( int a, StringBuffer buff, String b ) {
  buff.append( b );
  buff = new StringBuffer( b + a );
  a++;
  return buff;
}The above code is legal, I can reassign values to parameters that are not marked as final.
What cannot happen is that the values passed to the method can change.
The append call to buff means that the StringBuffer passed has been altered.
The assignment to buff of a new StringBuffer in no way changes the value of the reference, the original reference remains unchanged, in otherwords the buff variable outside the method call still points to its original object.
The increment of the parameter a does not change the value of the integer, you are reassigning a new value to a.
The value of int a outside the method call remains unchanged, the value passed to the method also remains unchanged.
Remember that variables are simply placeholders for things, in this case values. Primitive operators result in the variable value being replaced.
A integer value cannot be changed, 1 is always going to be 1, the same is true for any primitive datatypes.

Similar Messages

  • What is the difference between data base objects and runtime objects

    What is the difference between data base objects and runtime objects

    Hi raja,
    data base objects means u can have the presence of these objects in the database.So the tables,searchhelps,structures,lockobjects comes under these ones.
    Runtime objects are created and destroyed after the program ends, any changes we make to them are temporary only.
    regards,
    nagaraj
    Message was edited by: nagaraj kumar nishtala

  • Difference between Service data objects and process data object

    Hi
    Can anybody tell me what is the difference between SDO (Service Data Objects) & PDO (Process Data Objects).I am using 2 port PCI-CAN series 2 card.
    If anybody knows the answer then please reply.
    Thanking You

    Hi,
    See the online help file from our NI CANopen Library for LabVIEW for some basic informations about SDOs and PDOs.
    More information should be available from the web.
    DirkW
    Attachments:
    lvcanopenvhelp.zip ‏154 KB

  • Differences between using a Object Reference and the Object itself

    Example:
    public class Myclass
    //difference between
    Myclass myobj;
    //and
    Myclass myobj = new Myclass();
    can anyone help me?

    Both lines you showed declare an object reference.
    The first one is not explictely assigned a value and
    is thus implicetly assigned the null reference (= a
    reference pointing to no object). The latter is
    initialized with an reference to the newly created
    Object (new Myclass()).
    They're both given a value of null first.
    The second one is then given a value that points to that object that was created.
    If they were inside a method, then the first one's value would be undefined.

  • Difference between date info object in characteristics and keyfigure

    What is the difference between "date" data type in characteristic and keyfigure?
    Thanks in advance.
    Raj

    Hi Rajasekhar,
    If date is characteristics,query can be analysed based on date and filters can also be set using this date.
    If it is key figure query cannot be analysed based on date,
    Based on requirements,we have to decide whether it should be chatracteristic or key figure
    Regards
    Prakash

  • Difference between these 2 object groups

    Hi Everyone,
    Need to understand about object-group network below
    when i run the command    sh run object-group id subnet
    on fw1  it shows
    network-object 10.0.0.0 255.0.0.0
    network-object 172.16.0.0 255.240.0.0
    network-object 192.168.0.0 255.255.0.0
    Same command on firewall 2 shows   
    network-object object 10.0.0.0
    network-object object 172.16.0.0
    network-object object 192.168.0.0
    Need to understand if contents of both the firewall are same?
    also if i remove config   below from fw2
    network-object object 10.0.0.0
    network-object object 172.16.0.0
    network-object object 192.168.0.0
    and add  the
    network-object 10.0.0.0 255.0.0.0
    network-object 172.16.0.0 255.240.0.0
    network-object 192.168.0.0 255.255.0.0
    which are same as fw 1  will it make any difference to the fw2?
    Regards
    Mahesh

    Hi,
    Had not tested this myself before to I configured this on my firewall
    object network TEST
    subnet 10.10.10.0 255.255.255.0
    object network TEST-2
    subnet 10.10.20.0 255.255.255.0
    object-group network TEST-GROUP
    network-object object TEST
    network-object object TEST-2
    network-object 10.10.10.0 255.255.255.0
    network-object 10.10.20.0 255.255.255.0
    access-list TEST extended permit ip object-group TEST-GROUP any
    ASA(config)# sh access-list TEST
    access-list TEST; 4 elements; name hash: 0xd37fdb2b
    access-list TEST line 1 extended permit ip object-group TEST-GROUP any 0x47cc12eb
      access-list TEST line 1 extended permit ip 10.10.10.0 255.255.255.0 any (hitcnt=0) 0x365de33c
      access-list TEST line 1 extended permit ip 10.10.20.0 255.255.255.0 any (hitcnt=0) 0xc98d1b29
      access-list TEST line 1 extended permit ip 10.10.10.0 255.255.255.0 any (hitcnt=0) 0x365de33c
      access-list TEST line 1 extended permit ip 10.10.20.0 255.255.255.0 any (hitcnt=0) 0xc98d1b29
    It would seem to work even though it creates an ACL that has overlapping rules but this is nothing new when you deal with "object-group" and ACLs.
    I would imagine that as long as you are doing the changes under the same "object-group" then traffic should not be affected. The traffic that is already been allowed through the firewall will keep on going through the firewall and naturally new connections should still match the ACL rule since the same network should be in the ACL all the time since if you first add the new lines and then remove the old.
    I would imagine that this "object-group" is probably used in the some "deny" statement in an ACL since it lists all the Private IP address ranges.
    You can naturally browse through the configuration to see where this "object-group" is used with
    show run | inc
    - Jouni

  • Differences between business objects 4.0 and 4.1

    Hi,
    Can any one please provide the some blogs regarding the differences between the business objects 4.0 and 4.1.
    Thanks & Regards,
    Kavya.CH.

    Hi Kavya,
    Please refer following PDF for BI 4.1 new features added in each service pack.
    http://help.sap.com/businessobject/product_guides/sbo41/en/sbo41_whats_new_en.pdf
    You can have a look at the L1 and L2 presentations here:
    https://scn.sap.com/docs/DOC-40282
    http://scn.sap.com/docs/DOC-40283
    You can refer to the following doc to get more information on the new features and changes introduced in Web Intelligence 4.1.
    http://scn.sap.com/docs/DOC-43488
    Regards,
    Hrishikesh

  • Difference between plug in and normal bapis

    hai freinds when i am going through bapi's for project system module i am finding objects as projectdefination and projectdefinationPI, when i read the documentation it is giving as plug in waht is the exact difference between these two objects and bapis under them
    thanx
    afzal

    BAdIs Concept
    Use
    BAdIs or Business Add-Ins are used to create predefined enhancement options in the SAP ERP components, which are then appropriately implemented by the individual industry solutions, country variants, or even by partners and customers.
    Classic BAdIs have been present in ABAP-based SAP systems since Release 4.6. In contrast to the enhancement technology used up to then (for example, function module exits,) BAdIs are based on ABAP objects.
    The reimplementation of BAdIs for Release 7.0 had two main goals:
    · By integrating the BAdIs in the ABAP programming language through the new language elements GET BADIand CALL BADI, their performance was considerably enhanced.
    · The new BAdIs provide more flexibility in the conversion of predefined enhancement options through new, orthogonal properties such as contexts and filters.
    The new ABAP language elements and their additions ensure that these additional options can be used comfortably in ABAP programs. Within the Enhancement Framework, a new BAdI is always meant by the term BAdI. If there is explicit reference to the previous BAdI concept, such BAdIs are referred to as classic BAdIs.
    Definition of BAdIs
    Use
    When you define a BAdI, you must specify a name, a BAdI interface as the interface for the enhancement option, and the required filters. The name of a BAdI is in the same namespace as data types from the ABAP Dictionary, global classes, or interfaces. It is recommended that you use suitable prefixes, such as “BADI_”.
    A filter consists of a filter name and a data type (integer, string, and so on).
    In addition, you also define BAdI properties that are relevant at runtime of a program with the appropriate statements GET BADI and CALL BADI. For more information, see Instance Generation Mode and Multiple Use.
    Other properties that can be assigned to a BAdI include:
    ● An optional fallback BAdI implementation class. This option is used if no BAdI implementation with suitable filter conditions and no standard implementation is found.
    ● Whether the BAdI is internal or not.
    An internal BAdI must only be implemented by SAP and is not visible outside of SAP.
    ● Whether the BAdI is a function code or screen enhancement.
    A BAdI that is defined as a function code enhancement must not have any filters, must not be defined for multiple use, or assigned to any switch. It may contain methods that are independent of the actual function code enhancement.
    A BAdI that is defined as a screen enhancement must be defined in the instance generation mode for the reused instantiation and must not be defined for multiple use. It may contain BAdI methods that can be used to fill or evaluate the screen fields of the respective subscreens.
    Calling BAdIs
    Use
    After their definition and independent of an implementation, BAdIs can be called using a combination of the ABAP statements GET BADI and CALL BADI:
    · GET BADI FILTERS f1=x1 ... fn=xn – selects the BAdI implementations whose filter condition is met by the filter values specified in the statement. The BAdI implementation classes assigned to the selected implementations are instantiated and passed to a simultaneously created BAdI object which serves as a handle for the implementation.
    · CALL BADI badi->meth – addresses the BAdI object which passes the call of BAdI methods to the object plug-ins known to the BAdI handle.
    For detailed information about these statements, see the ABAP Keyword Documentation.
    In the context of the Enhancement Framework, the above statements together form the enhancement spot element calls of an explicit enhancement option. Conceptually, they are part of the definition of an enhancement option.
    Procedure
    For a multiple-use BAdI, several implementations can be called one after the other using CALL BADI. The sequence in which several object plug-ins are called consecutively is the same in repeated calls, but it can be determined in advance in the BADI_SORTER enhancement spot using the predefined BAdI BADI_SORTER:
    1. Create the new implementation BADI_SORTER.
    2. Enter the name of the BAdI whose object plug-ins you want to call in a sorted sequence as the filter condition for the BADI_NAME filter.
    3. Create a screen enhancement to query any kind of sort criterion.
    The Enhancement Builder then displays this subscreen with each implementation of the BAdI to be sorted.
    4. Implement the methods of the BAdI interface IF_BADI_SORTER according to your sort criteria in the BAdI implementation class.
    Without this procedure, the sequence is undefined.
    Reward me if its useful.
    Regards
    Abhay.
    Rewards point.

  • LSMW Difference between 4.7 and ECC 6.0

    Hi Experts,
    can anyone point out the difference between the LSMW objects/options available in 4.7 and ECC 6.0. We have developed lot of objects in 4.7 thru BDC, IDOC, Report & Bapi's, like to know whether these will be affected and if so what is to be noted during upgrade.
    Also like to know what addtional objects or features are avaialble in ECC 6.0 LSMW?

    Do not double post the same question:
    https://forums.sdn.sap.com/profile.jspa?userID=3984345
    Markus

  • Difference between a static class and singleton

    What is the difference between a static object and a singleton ?
    for example:
    1 )
    public class MyObject {
    static MyObject singleton ;
    public static MyObject getInstance() {
    if (singleton ==null) singleton = new MyObject ();
    return singleton;
    private MyObject () {
    supe();
    public void myMethod() {
    2 )
    public class MyObject {
    private MyObject () {
    supe();
    public static void myMethod() {
    If I need to call the myMethod() , witch of this solution is better ?
    // case 1
    MyObject.getInstance().myMethod()
    // case 2
    MyObject.myMethod()
    .....

    This has been discussed a lot here.
    Use the forum's search feature, or, since it's not necessarily reliable, use google.
    For many intents and purposes, they're equivalent.
    However, with a singleton you can implement an interface, and get polymorphic behavior. You can't do with with a class full of static methods (which, by the way, is NOT a static class).

  • Difference between B_USERSTAT and B_USERST_T

    Hi,
    I would like to know what is the basic difference between the authorization objects B_USERSTAT and B_USERST_T. The values within them are exactly the same. Where is the point of difference?
    Thanks and regards,
    Vivek Pandey

    Hi,
       B_USERSTAT->
    Definition
    User status authorization object
    With this authorization object you protect the setting or deletion of user status in the general status management of orders, projects, network plans, etc.
    Defined fields
    The authorization object checks the fields
    Object type
    Status schema
    Authorization key of the user status in question
    Activity
    To set or delete a particular user status you must have saved the authorization for the combination of object type/status schema/authorization key/activity in your user master.
    The field "Activity" is set by the system depending on the action to be performed, and can take the following values:
    01 - set
    06 - delete
    B_USERST_T->
    Integration
    The group functionality roles are "delta" roles of the Service Desk Roles
    . To use this functionality
    1. Assign the default Service Desk role and the analogous group functionality role, to the user, in the user administration (transaction SU01).
    SAP_SUPPDESK_CREATE and
    SAP_SUPPCF_CREATE
    2. Deactivate the following authorization objects in the Service Desk roles, in the role maintenance (transaction PFCG):
    ¡ B_USERSTAT
    ¡ B_USERST_T
    Regards

  • Difference between abap object and function

    hi all,
    i read the book on abap object of the difference between abap object and classical abap.
    i know that there is only 1 instance of a specific function group but somehow i still not so clear why subsequent vehicle cannot use the same function. i also can use the do and loop to call the function? if cannot then why?
    hope can get the advice.
    thanks
    using function *********
    function-pool vehicle.
    data speed type i value 0.
    function accelerate.
    speed = speed + 1.
    endfunction.
    function show_speed.
    write speed.
    endfunction.
    report xx.
    start-of-selection.
    *vehicle 1
    call function 'accelerate'.
    call function 'accelerate'.
    call function 'show_speed'.
    *vehicle 2
    *vehicle 3
    *****abap object*******
    report xx.
    data: ov type ref to vehicle,
             ov_tab type table of ref to vehicle.
    start-of-selection.
    do 5 times.
    create object ov.
    append ov to ov_tab.
    enddo.
    loop at ov_tab into ov.
    do sy-tabix times.
    call method ov->accelerate.
    enddo.
    call method ov->show_speed.
    endloop.

    Hi
    Now try this:
    REPORT ZTEST_VEHICLEOO .
    PARAMETERS: P_CAR   TYPE I,
                P_READ  TYPE I.
    *       CLASS vehicle DEFINITION
    CLASS VEHICLE DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA: MAX_SPEED   TYPE I,
                    MAX_VEHICLE TYPE I,
                    NR_VEHICLES TYPE I.
        CLASS-METHODS CLASS_CONSTRUCTOR.
        METHODS CONSTRUCTOR.
        METHODS ACCELERATE.
        METHODS SHOW_SPEED.
        METHODS GET_SPEED EXPORTING E_SPEED TYPE I.
      PRIVATE SECTION.
        DATA: SPEED      TYPE I,
              NR_VEHICLE TYPE I..
    ENDCLASS.
    *       CLASS vehicle IMPLEMENTATION
    CLASS VEHICLE IMPLEMENTATION.
      METHOD CLASS_CONSTRUCTOR.
        NR_VEHICLES = 0.
      ENDMETHOD.
      METHOD CONSTRUCTOR.
        NR_VEHICLES = NR_VEHICLES + 1.
        NR_VEHICLE  = NR_VEHICLES.
      ENDMETHOD.
      METHOD ACCELERATE.
        SPEED = SPEED + 1.
        IF MAX_SPEED < SPEED.
          MAX_SPEED   = SPEED.
          MAX_VEHICLE = NR_VEHICLE.
        ENDIF.
      ENDMETHOD.
      METHOD SHOW_SPEED.
        WRITE: / 'Speed of vehicle nr.', NR_VEHICLE, ':', SPEED.
      ENDMETHOD.
      METHOD GET_SPEED.
        E_SPEED = SPEED.
      ENDMETHOD.
    ENDCLASS.
    DATA: OV     TYPE REF TO VEHICLE,
          OV_TAB TYPE TABLE OF REF TO VEHICLE.
    DATA: V_TIMES TYPE I,
          FL_ACTION.
    DATA: V_SPEED TYPE I.
    START-OF-SELECTION.
      DO P_CAR TIMES.
        CREATE OBJECT OV.
        APPEND OV TO OV_TAB.
      ENDDO.
      LOOP AT OV_TAB INTO OV.
        IF FL_ACTION = SPACE.
          FL_ACTION = 'X'.
          V_TIMES = SY-TABIX * 2.
        ELSE.
          FL_ACTION = SPACE.
          V_TIMES = SY-TABIX - 2.
        ENDIF.
        DO V_TIMES TIMES.
          CALL METHOD OV->ACCELERATE.
        ENDDO.
        CALL METHOD OV->SHOW_SPEED.
      ENDLOOP.
      SKIP.
      WRITE: / 'Higher speed', VEHICLE=>MAX_SPEED, 'for vehicle nr.',
                VEHICLE=>MAX_VEHICLE.
      SKIP.
      READ TABLE OV_TAB INTO OV INDEX P_READ.
      IF SY-SUBRC <> 0.
        WRITE: 'No vehicle', P_READ.
      ELSE.
        CALL METHOD OV->GET_SPEED IMPORTING E_SPEED = V_SPEED.
        WRITE: 'Speed of vehicle', P_READ, V_SPEED.
      ENDIF.
    Try to repeat this using a function group and I think you'll undestand because it'll be very hard to do it.
    By only one function group how can u read the data of a certain vehicle?
    Yes you can create in the function group an internal table where u store the data of every car: in this way u use the internal table like it was an instance, but you should consider here the example is very simple. Here we have only the speed as characteristic, but really we can have many complex characteristics.
    Max

  • 1)Now I use Lightrom 5.7 how to upgrade to 6 or CC? 2) What is the difference between 6 and CC vercion? 3) When I used lightromm 3, I could see inEXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is ve

    1)Now I use Lightrom 5.7 how to upgrade to 6 or CC?
    2) What is the difference between 6 and CC version?
    3) When I used lightromm 3, I could see in EXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is very sad  I am stiil waiting and hope that it would be possibble in the new  versions. Or this indication may  possible by setting?

    1)Now I use Lightrom 5.7 how to upgrade to 6 or CC?
    Purchase the standalone upgrade from here: Products
    Download CC version from here: Explore Adobe desktop apps | Adobe Creative Cloud
    2) What is the difference between 6 and CC version?
    See this comparison chart: Compare Lightroom versions | Adobe Photoshop Lightroom CC
    3) When I used lightromm 3, I could see in EXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is very sad  I am stiil waiting and hope that it would be possibble in the new  versions. Or this indication may  possible by setting?
    Rob Cole's ExifMeta plugin displays the Subject Distance field (and much more).  Unfortunately, his Web site appears to be down again.  He used to be very active here, but he hasn't posted in several months.

  • What's the difference between a not-initialed object and a null object

    hi guys, i wanna know the difference between a not-initialed object and a null object.
    for eg.
    Car c1;
    Car c2 = null;after the 2 lines , 2 Car obj-referance have been created, but no Car obj.
    1.so c2 is not refering to any object, so where do we put the null?in the heap?
    2.as no c2 is not refering to any object, what's the difference between c2 and c1?
    3.and where we store the difference-information?in the heap?

    For local variables you can't have "Car c1;" the compiler will complain.That's not true. It will only complain if you try to use it without initializing it.
    You can have (never used, so compiler doesn't care):
    public void doSomething()
       Car c1;
       System.out.println("Hello");
    }or you can have (definitely initialized, so doesn't have to be initialized where declared):
    public void doSomething(boolean goldClubMember)
       Car c1;
       if (goldClubMember)
           c1 = new Car("Lexus");
       else
           c1 = new Car("Kia");
       System.out.println("You can rent a " + c1.getMake());
    }

  • Differences between Oracle BAM and Oracle BI and Question BAM  Data Objects

    Hi,
    I have two questions.
    1. Can someone tell me differences between Oracle BAM and Oracle BI?
    My understanding about Oracle BAM is, we use BAM to build Dashboards or Reports.
    We can also build DashBoards or reports using Oracle BI.
    I am not able to understand why Oracle has two tools for same purpose?
    Which tool is more powerful and user friendly(Oracle BI or Oracle BAM)?
    2. Every time we plan to develop Dashboard or report in BAM, we need to create BAM ADC Data Object to store Data (i.e first step is to get data from external database or application and second step is to store data in BAM ADC data object).
    My understanding is we have an extra step(i.e creating Data Object) in Oracle BAM to develop a report or DashBoard
    I am wrong pl correct me?
    Regards,
    Shanti Nagulapalli.

    Oracle 11g has many advanced features in PL/SQL over Oracle 9i.
    refer here,
    http://www.oracle.com/technetwork/database/features/manageability/9i-to-11g-real-world-customer-exper-133754.pdf
    http://www.oracle.com/global/de/upgradecommunity/artikel/upgrade11gr2_workshop2.pdf
    http://www.compuworks.com/events/view/233.pdf
    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getCourseDesc?dc=D52601GC10&p_org_id=15942&lang=US
    Thanks

Maybe you are looking for

  • Oracle.jbo.domain.TimestampTZ  issue

    JDeveloper Version 11.1.1.5.0 I have a issue with the oracle.jbo.domain.TimestampTZ field. I have a Search screen, when I search on the oracle.jbo.domain.TimestampTZ fields select the date time for the picker, I get the following exception JBO-26023:

  • Can't modify/delete Outlook 2010 Contact Group

    I've got a user who created a new Contact Group in Outlook 2010 and now can't modify or delete the group.  Other groups she's created before or since do not exhibit this behavior.  Also, when you bring up the properties of the group, the window looks

  • Unresponsive script error from "chrome://browser/content/browser.js:5582"

    I always get a unresponsive script error from chrome://browser/content/browser.js:5582 . If I uninstall and reinstall firefox, It'll stop for awhile. My os is ubuntu 10.04 64 bit. == User Agent == Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit

  • To Delete a folder in LR

    LR allows you to remove or delete pictures, and you can make a new folder which uses explorer and makes the folder on the hard drive as well as in LR. However, if you decide to delete a folder in LR, it will do so, but the folder is still on the hard

  • Docbook.xsl processing error on XSQL XML output

    Hi all, I've got an XSQL page query which returns a docbook-schema-valid document in XML. I've written a simple xsl stylesheet to test the output and the results are as expected. I now want to use the docbook.xsl designed by Norman Walsh but I'm gett