How to make an object mutable?

Can any one tell me how to make an object mutable?
Following is Class X & Y?
class Y
public static void main(String arg[]) {
X a1=new X();
Object a=a1.get();
System.out.println(a.toString());
a1.set(a);
System.out.println(a.toString());
class X implements Serializable
public Object get(){
return new Object();
public synchronized void set(Object o)
o=null;
In my class Y when i say
a1.set(a);
I want local Object a of main method should be nullified.
Can it be possible if yes what is the way or code to be applied so that
my next a.toString() statement will give me NullpointerException.

Isn't it more accurate to say that object references are passed by value?
OP -- Basically you can't to what you want to do. When you "pass an object" as a method parameter, what you're really passing is a copy of the reference that points to the object. You now have two refs pointing to the same object--one in the caller and one in the method being executed. Setting either of those refs to null does NOT affect the object itself, and does NOT affect the other ref. It just means that the ref that's been set to null no longer points to any object.
If you want the called method to make a change that the caller can see, you need to either 1) return a value from the method, 2) encapsulate the object to be changed as a member of new class, or 3) pass the object to be changed as the single element of an array. I would STRONGLY recommend against (3) as a way to simulate pass by reference. Better to examine your design and determine whether (1) or (2) more closely matches what you're really trying to accomplish.

Similar Messages

  • How to make any object self-shining?

    hi,
    i guess thats an easy question, but i dont know where to look for the answer.
    so how to make any object self-shining like the infamous colorcube, so that one does not need to place any light?
    and am I right in my assumption that doing so will reduce the need of rendering power, since lights dont have to be computed?
    thanx,
    Usul

    I'm not sure what you mean here- if your object is lit then lighting will need to be calculated. If you don't want shapes to be lit, I think you can disable it by calling setLightingEnable(false) in their materials.

  • How to make an object distributed across multiple jres?

    Hi,
    We used cache data mechanism for performance tuning. It will store data in static variable (Hashtable) and get initialized when app starts . We are using IPlanet Application Server and
    Using 6 KJS engines. This object ( Hashtable) is not distributed across all JRES.It has to reinitialize data again when request goes to any other KJS.
    We avoid sharing data in session and request, as data is huge.
    Can any one help us how to make this object distributed across all KJSs?
    Thanks in advance.
    raj

    We used cache data mechanism for performance tuning.
    It will store data in static variable (Hashtable) and
    get initialized when app starts.
    We are using IPlanet Application Server and
    Using 6 KJS engines. This object ( Hashtable) is not
    distributed across all JRES. It has to reinitialize
    data again when request goes to any other KJS.
    We avoid sharing data in session and request, as data
    is huge.
    Can any one help us how to make this object
    distributed across all KJSs?When you say 'initialized when app starts' do you mean iPlanets StartUp classes, rather than the Servlets init() ? Given a 'huge' dataset, avoid the latter.
    I'd suggest that a better approach is to implement this as an Entity Bean and accessed from Session bean and using Value Objects to return the data subsets.
    Checkout the Java Pet Store
    http://java.sun.com/blueprints/code/jps13/datasheet.html

  • HOw to make an Object oriented alv respond to double click

    Hi all,
    HOw to make an Object oriented alv respond to double click.SAmple code will be helpful.
    Thanks in advance,
    Alex.

    Hi,
    1. Create a Control (for Custom and Split Containers only)
    2. Instantiate a Container Object (in case of Custom and Split Containers, specify the control which is created by us in Screen painter) CREATE OBJECT
    3. Instantiate an Object of the kind of report that has to be displayed (List, Grid or Tree). CREATE OBJECT . Here we need to specify the Parent Container as the so that it sits in that container.
    4. Call appropriate methods to display the report on the screen. CALL METHOD ->
    DATA : g_dock TYPE REF TO cl_gui_docking_container,
    g_split TYPE REF TO cl_gui_easy_splitter_container,
    g_cont1 TYPE REF TO cl_gui_container,
    g_cont2 TYPE REF TO cl_gui_container,
    g_grid1 TYPE REF TO cl_gui_alv_grid,
    g_grid2 TYPE REF TO cl_gui_alv_grid.
    i_mara is an internal table of structure MARA
    SELECT * FROM mara INTO TABLE i_mara.
    i_kna1 is an internal table of structure KNA1
    SELECT * FROM kna1 INTO TABLE i_kna1.
    To create an Object of type Docking Container
    CREATE OBJECT g_dock
    EXPORTING
    side = cl_gui_docking_container=>dock_at_top
    extension = 200 .
    To Create an Object of Type Split Container. Here we can see that the Docking *Container Created above has been used as a parent .
    CREATE OBJECT g_split
    EXPORTING
    parent = g_dock
    orientation = 1 .
    Easy Split container splits one Control into 2 manageable controls, each of them is used * to handle one GUI Container each
    g_cont1 = g_split->top_left_container.
    g_cont2 = g_split->bottom_right_container.
    To Create an Object of type Grid . Here we can see that the Left Split Container * Created above has been used as a parent .
    CREATE OBJECT g_grid1
    EXPORTING
    i_parent = g_cont1 .
    To Create an Object of type Grid . Here we can see that the Right Split Container * Created above has been used as a parent .
    CREATE OBJECT g_grid2
    EXPORTING
    i_parent = g_cont2 .
    The method of Grid Control Object is used to display the Data.
    CALL METHOD g_grid1->set_table_for_first_display
    EXPORTING
    i_structure_name = 'MARA'
    CHANGING
    it_outtab = i_mara[] .
    The method of Grid Control Object is used to display the Data.
    CALL METHOD g_grid2->set_table_for_first_display
    EXPORTING
    i_structure_name = 'KNA1'
    CHANGING
    it_outtab = i_kna1[] .
    Regards
    Hari

  • How to make Shape3D object translucent

    Hi,
    How to make Shape3D object (like Box, Cylinder) translucent? I tried the below option but the box is not becoming translucent at all.
    final PhongMaterial redMaterial = new PhongMaterial();
              redMaterial.setSpecularColor(Color.rgb(10, 255, 15, opacity));
              redMaterial.setDiffuseColor(Color.rgb(10, 255, 15, opacity));
    final Box box = new Box(width,height,depth);
    box.setMaterial(redMaterial);
    When opacity is 1, the color of the box will be Green, when it is 0 the color becomes black.
    Is there any way the box can be made translucent?

    There is at least one unresolved issue concerning PhongMaterial's transparency: RT-28874.
    I'm neither able to get it working properly. My red Sphere also fades to black while varying the opacity value from 1.0 to 0.0.
    August

  • How to make an object getting out of the screen ?

    Hello everybody !
    I am creating a game introduction with Flash pro CS6 and here's is my problem.
    I want a object in my animation to leave the screen, but I dont know how to do it.
    Is there for example, a way to delimited the working area, so that when I make an object go out of this area, it does not appear in my final animation ( no matter the format, .avi, .mov, spritesheets ... ) or can eventualy be "cut" ( if I make my object half inside the working arear and half outside ) ?
    Is there an other way to do this ?
    Thanks !

    Using a mask might be one way.

  • How to make text/objects move nonlinear speed on AE CC?

    Hi,
    I was wondering two questions:
    1) how to make "text holders" that has small animation. Here is an example from a video http://www.youtube.com/watch?v=5oSWt84VoAg (0:41).
    2) how to move objects with increasing speed and soft slow down. I know how to change speed, but how to make it so that it is only accelerating and slowing down? Same examle can be found from the clip above with the place holders and texts.
    Thank you for your help. If there is same kind of discussion going on please let me know. I could not find it.

    All of what you want to do comes down to the fine art of learning how to magle curves in the graph editor, which is nothing you can learn from just watching totorials. You learn it by doing and collecting experience.
    Mylenium

  • How to make an object of inner class and use it ?

    Hi tecs,
    In my JSF application i have a need to make an inner member class in one of my bean class.
    How can i make the object of this class?(what should be the entry in faces-config)
    And there are text box and check box (in the JSP) associated with the elements of this inner class. What should be the coding in JSP so that elements in the JSP can be linked with the corresponding members of the inner class ?
    Plz help.
    Thnx in advance.

    Hi
    I am havin 10 text boxes in my application.
    But out of 10 , 3 will be always together(existence of one is not possible without the other two.)
    Now i want to create a vector of objects ( here object will consist of the value corresponding to these three boxes),there can be many elements in this vector.
    So i m thinking to make an inner class which have three String variables corresponding to these text boxes that exists together.
    What can b done ?

  • How to make the objects got even distance in the Blend?

    Wondering anyone has the same experience or not? I blend 2 circles together and adjust the spine from a straight line to wave curve line by adding points and adjusting the handles of the points. The space between the objects along the spine turn to uneven after that. I tried to use the "specified distance" in the option and add more points and modify the handles again. However, all in vain. Finally, I need to expand the blend and adjust the distance of those objects manually. Any suggestions to correct the stupid way? Thanks.

    There is not really any way to get even spacing in a blend when the spine path has uneven curvature. (What the Specify Distance option does is take the length of the path, and divide it by the requested distance to determine the number of blend steps, but then once it has that number, they get spread out by exactly the same algorithm that is used when the number of steps is specified by a fixed number or calculated from the color difference.)
    The length of the direction handles on a spine path affects the placement of objects, with longer direction handles pushing the blend steps away from the anchor point, and shorter direction handles pulling them in towards it. This tends to make the objects more tightly spaced when the path has sharp curves, and more loosely spaced where it is flatter.
    If the direction handles are of equal length, and the distance between the two direction points is the same as their length, such as occurs on a circle, then the "pulls" balance out and the spacing ends up even. But when the curvature varies, so does the spacing.
    This can be used to advantage to get non-linear gradations, by making a straight line and then pulling out direction handles that lie along the line. It can also be used to make objects on an elliptical orbit appear to be spaced in perspective, since they are closer together at the sharp ends of the ellipse and farther apart at the flat sides.
    Often, however, what is desired is spacing that is independent of the curvature, such as you get with scatter brushes.
    It was fully intended when live blends were implemented in AI 8 that even spacing would be an option, and would indeed be the default option, with logarithmic spacing and direction-handle controlled spacing being two other choices. The direction-handle controlled spacing was just implemented first not because it was most useful (it isn't) but because, believe it or not, it is
    easiest. (Points on the interior of a bezier curve are natively addressed by t-value, which is a fraction of the direction handle distance. To obtain a position that is a fraction of the path length, one must first flatten the entire path into a polygonal approximation, then find the position by adding up the lengths of the flat segments. In contrast, one can obtain a point at a given fraction of the bezier t-value without flattening the path. This is the reason, by the way, that while scatter brushes have more even spacing between objects, they do not fit as tightly to the bezier as blend steps do - they are being placed on a straight line approximation of the path instead of directly on it.) The intention was to get the easy case of t-value based spacing working, and then add the harder case that requires flattening.
    It turned out that we did not have time to add the extra options for AI 8, so it shipped as is. Then Macromedia sued us over live blends because Freehand had them first and as part of the settlement we had to promise to stop enhancing them. Now that the two companies have merged, that issue is moot, so enhancing blends is now a possibility for future versions of Illustrator. (All of you who complain about the cool features that Freehand has had for years and Illustrator hasn't, as if it were perverse and intransigent of Adobe not to follow suit, might want to keep in mind that copying the features of another company's software is often not allowed.)
    In the meantime, scatter brushes can be a good alternative if all your blend steps are the same, but obviously they won't work if your blended shapes are changing along the path.

  • How to make an object or a menu to stick to the left edge of the screen?

    I want the left menu to look like here http://muserocket.com/tf/bonesa/  how to make it stick to the left on any monitor?

    Use the Pinning control in the Control Strip to pin your sidebar to the top left of the browser window.

  • How to make serializable object in webdynpro?

    Hi
    I have written the following code... when i am executing i am getting the following error..........
    <b>javax.xml.rpc.soap.SOAPFaultException: Deserialisation failed</b>
    I think is it becoz of data... how to make it serializable
         Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData customer = new Request_Z_BAPI_CUSTOMER_CHANGE_WS_customerChangeFromData();
         ComplexType_CustomerChangeFromData complexType = new ComplexType_CustomerChangeFromData();
         ComplexType_Bapikna101 bapi = new ComplexType_Bapikna101();
         Bapikna101 bapi1 = new Bapikna101();
         bapi1.setCity("RIYAD");
         bapi1.setCountraiso("SA");
         bapi1.setCountrniso("SA");
         bapi1.setCountry("SA");
         bapi1.setCountryiso("SA");
         bapi1.setFaxNumber("12345678");
         bapi1.setFirstName("First Name");
         bapi1.setInternet("[email protected]");
         bapi1.setDateBirth("12.12.2006");
         bapi1.setLanguIso("EN");
         bapi1.setName("Name");
         bapi1.setName3("Name 3");
         bapi1.setName4("Name 4");
         bapi1.setRegion("GB");
         bapi1.setFormOfAd("Address");
         bapi1.setStreet("Street");
         bapi1.setPostlCode("12345");
         bapi1.setLangu("X");
         bapi1.setTelephone("12345678");
         bapi1.setTelephone2("12345678");
         bapi1.setCurrency("INR");
         bapi1.setCurrencyIso("INR");
         bapi1.setOnlyChangeComaddress("X");
         complexType.setCustomerNo("0000040009");
         complexType.setPiDistrChan("01");
         complexType.setPiDivision("01");
         complexType.setPiSalesorg("QNIN");
         customer._setUser("abap");
        customer._setPassword("quinnox");
         CustomerChangeFromData data = new CustomerChangeFromData();
         data.setPiAddress(bapi1);
         //bapi.setOriginalBean(bapi1);
         complexType.setOriginalBean(data);
         wdComponentAPI.getMessageManager().reportSuccess(" "+complexType.getOriginalBean().getCustomerNo());
         wdComponentAPI.getMessageManager().reportSuccess(" "+complexType.getPiAddress());
         wdContext.nodeRequest_Z_Bapi_Customer_Change().bind(customer);
         complexType.setPiAddress(bapi);
         wdComponentAPI.getMessageManager().reportSuccess(" "+data.getPiAddress().getCity());
         customer.setParameters(complexType);
    help me
    Best Regards
    Ravi Shankar B

    Hi ashuthosh,
      What is the structure of your import and Export parameters of your RFC.
    There are 2 ways to acheive it.
    In the RFC either
    1. Use a Table parameter
    2. Use a Export Structure
    If you use a Table parameter in your RFC then in your webdynpro when you import your adaptive RFC model you would get the Table as a class.
    Assume your RFC/BAPI is called "Bapi_RFC_Insert"
    write the code
    Bapi_RFC_Insert in = new Bapi_RFC_Insert();
    wdContext.nodeBAPI_RFC_Insert_InputElement().bind(in);
    <TableName> <someName> = new <TableName>
    <someName>.setTabValue1();
    <someName>.setTabValue2();
    in.add<>(<someName>);
    This should pass values as a batch.
    You can also do this using Export parameters. But a table is much better.
    Let me know if you require more information.
    regards
    ravi

  • How to make this object static ?

    Hi,
    I have such an InputStream :
    InputStream kombinace = getClass().getResourceAsStream("/kombinace.txt");is there anyway how to make it static ?
    thanks for help

    BigDaddyLoveHandles wrote:
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    InputStream in = loader.getResourceAsStream(path);
    I'm not sure that this is guaranteed to work since the class loader you have obtained from the current thread may not be the one that holds the resource.

  • How to make shape objects clickable/selectable in transformgroups in java 3

    I am building a visualizer program that has Java 3D components inside Swing components. I have a branchgroup inside a canvas3d inside a simpleuniverse, which is added to a JTabbedPane. Inside the branchgroup I have multiple transformgroups each with one shape in them (box, cone, sphere, cylinder). Each transformgroup has the ability to rotate, zoom, and tranlate objects because I have incorperated a MouseZoom, MouseRotate, and MouseTranslate object as from the Java 3D library functions (these are applied to each transformgroup every time one is created and added to the branchgroup). My problem is that I am trying to make these shapes clickable/sectable/dragable/dropable on the screen - currently when I try to translate ONE object all the shapes move on the screen and I cannot get just one shape to move (all shapes move when I only want one to). How do I make only one shape move when it is clicked?
    I know the question is kind of out there and specific so if anyone knows how to generically give transformgroups/shapes drag and drop properties that would also help a great deal. Does anyone know how to to this? Thanks a ton.

    shape uses the contains and intersects methods, is that what you need? Without code it is hard to guess what is required.

  • How to make versionable object of different class than Document?

    In the programmers reference is that every PublicObject can be versioned, but there are only samples for versioning documents. I would like to keep history on folder hierarchy changes, so I think I need a Folder that can be versioned.
    The question is how to do this?
    Should I override isVersionable method in subclass of Folder to return true?
    Please help

    Hi
    I am havin 10 text boxes in my application.
    But out of 10 , 3 will be always together(existence of one is not possible without the other two.)
    Now i want to create a vector of objects ( here object will consist of the value corresponding to these three boxes),there can be many elements in this vector.
    So i m thinking to make an inner class which have three String variables corresponding to these text boxes that exists together.
    What can b done ?

  • How to make local Object Request as Transportable Request

    Hi,
    I have saved as local Object , Now i need to make has transportable request.
    Can any body tell how to do?
    Regds,
    C.V.
    Message was edited by:
            P.C.V.

    Hi Chakri,
    Drag and drop that object into right screen of Transport connector tool and then click on Click on Truck button to create the Transport request.
    With rgds,
    Anil Kumar Sharma .P

Maybe you are looking for

  • Using a US Airport Extreme in England

    I have an Airport Extreme that I've been using in my home in Maryland for wi-fi. Now I'm moving to England. Will the Airport Extreme work over there? I see two potential issues: The plug that's supplied won't fit in the British outlet. And do they us

  • I can not send a message to someone from my iPad mini unless they have an I phone how do I change this

    I can not send a message to any one of my contacts unless they have an iPhone or I pad how can I sync my contacts to get and receive messages on this I lad mini

  • How to format and display xml file as displayed in IE

    I want to display the xml file as it is displayed in Internet Explorer. Which component I should use and how? Thanks in advance Sachin

  • File sizes not shown in Finder

    Only a few sizes are shown for applications and folders in the Finder window. If I select a folder and then press Command-I, the size will be shown in the information window, but still not showing in Finder. Any thoughts? Macbook 100g   Mac OS X (10.

  • WRT54G v6, Weird Problem

    My new WRT54G router was working fine for a couple weeks, both wired and wireless performance, on one desktop(wired) and two laptops(wireless). Recently I've been having a strange problem with the wireless; it connects with an excellent signal, and I