Changing a primitive being passed into a method

is there any way (without using the wrapper classes) to change, say an int, that's being passed in?

No, because Java passes by value. And you cannot change it via the wrapper classes either, because they're immutable and Java passes references by value, too.

Similar Messages

  • Click event on a item renderer stops data being passed

    Hi
    I'm trying to create a item renderer based on a Canvas, this renderer is then used in a List component. I'm trying to get a click event fired when the user clicks on one of the items in the List. I'm also formatting the data being passed into the item renderer to do this I'm overriding the set data property like this:
    override public function set data(value:Object):void
    title.text = value.marketName;
    sellPrice.text = value.sellPrice;
    buyPrice.text = value.buyPrice;
    change.text = value.percentageChangeOnDay;
    var i:String = "-";
    if(String(value.percentageChangeOnDay).indexOf(i))
    change.styleName = "PositiveChange";
    else
    change.styleName = "NegativeChange";
    When I add a click event to my item renderer like this,
    <view:DisplayItem click="itemClickedEvent( event )" />
    I get a null reference error in my set data function. If I remove the click event the data is passed correctly, I've also found that if I use a rollOut event like this,
    <view:DisplayItem rollOut="rolledOverEvent( event )"/>
    the data is passed fine and the event works too, it seems that click events cause the data not to be passed.
    Why does having a click event cause this problem? How can I have a click event on the item renderer and still format my data?
    Cheers
    Stephen

    Found out that I can use the itemClick event of the List component I'm using my item renderer in, so really my item renderer does not need a click event.

  • Changing the value of a parameter that has been passed into an SSRS 2008 R2 report

    I support 200+ reports that all use stored procedures and have many drill downs with built in URLs.
    I want to do the below to avoid creating a brand new parameter that I will have to add to literally hundreds of places.
    We have what I'll call Param1 that receives a value from the user.  That Param1 is passed to the stored procedure(s) for the report and also embedded in any Action URLs for drill downs to other reports from that report.  All works great.
    Now I have a need to concatenate a string to whatever value they supplied which provides context for the environment in which they are running.  The reason I want to do this instead of creating a new parameter is because I need this in all my reports
    and as stated above I would have to make 100s of changes to make that happen.  If I can figure out a way to concatenate a value to the existing Param1 value I can greatly reduce the number of changes.
    I can't seem to be able to find a way to modify the value on an existing parameter that is passed into the report prior to report execution.
    I get an error when I simply try to concatenate something to the parameter in its Default property.
    I can't find a way to update a parameter value in the Report Code block.  There don't appear to be any methods available on the Parameter Collection to set the value of a parameter.
    Any ideas?
    Thanks!
    Nathan 

    Create a new parameter. Mark it internal, set it's value by expression to:
    =User!UserId+"MyNewValue"
    and pass it to the proc?
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • Passing Objects to methods, why aren't they changed permanently?

    If an object is passed by reference, and primitive types are passed by value; then why does the following programme not alter the original values of A and B?
    I m trying to pass parameters into a method so that they can be altered and returned, can any one suggest a way to do this.
    Thanks,
    Ben.
    public class Application2 {
    Application2(){ }
         void goProc(){
              Integer A=new Integer(4);
              Integer B=new Integer(6);
              add(A,B);
              System.out.println("A2 " + A);
              System.out.println("B2 " + B);
         void add(Integer A,Integer B){
              System.out.println("A " + A);
              System.out.println("B " + B);
              A=A.valueOf(String.valueOf((A.intValue()+B.intValue())));
              System.out.println("added " + A);
    //Main method
         public static void main(String[] args) {
              Application2 App = new Application2();
              Integer A=new Integer(4);
              Integer B=new Integer(1);
              App.add(A,B);
              System.out.println("A1 " + A);
              System.out.println("B1 " + B);
              App.goProc();
    OUTPUT.
    A 4
    B 1
    added 5
    A1 4
    B1 1
    A 4
    B 6
    added 10
    A2 4
    B2 6

    If an object is passed by reference,It isn't. Instead, a pointer to the object is passed
    by value.That is exactly what passing by reference is.
    Objects passed by reference can be modified and it will affect the caller, but modifying the reference (assiging a new object) won't affect the caller.
    I m trying to pass parameters into a method so that
    they can be altered and returned, can any one
    suggest a way to do this.I think this is bad OO programing, it results in less readable code and may be hard to debug. Better is to make the method return the result and let the caller assign the new value. (This is my personal oppinion at least)

  • How to call a java method so I can pass a file into the method

    I want to pass a file into a java method method from the main method. Can anyone give me some help as to how I pass the file into the method - do I pass the file name ? are there any special points I need to put in the methods signature etc ?
    FileReader file = new FileReader("Scores");
    BufferedReader infile = new BufferedReader(file);
    Where am I supposed to put the above text - in the main method or the one I want to pass the file into to?
    Thanks

    It's a matter of personal preference really. I would encapsulate all of the file-parsing logic in a separate class that implements an interface so that if in the future you want to start taking the integers from another source, e.g. a db, you wouldn't need to drastically alter your main application code. Probably something like this, (with an assumption that the numbers are delimited by a comma and a realisation that my file-handling routine sucks):
    public class MyApp{
    public static void main(String[] args){
    IntegerGather g = new FileIntegerGatherer();
    Integer[] result = g.getIntegers(args[0]);
    public interface IntegerGatherer{
    public Integer[] getIntegers(String location);
    import java.io.*;
    public class FileIntegerGatherer implements IntegerGatherer{
    public Integer[] getIntegers(String location){
    FileInputStream fs=null;
    try{
    File f = new File(location);
    fs = new FileInputStream(f);
    byte[] in = new byte[1024];
    StringBuffer sb = new StringBuffer();
    while((fs.read(in))!=-1){
    sb.append(new String(in));
    StringTokenizer st = new StringTokenizer(sb.toString(),",");
    Integer[] result = new Integer[st.countTokens()];
    int count = 0;
    while(st.hasMoreTokens()){
    result[count]=Integer.valueOf(st.nextToken());
    count++;
    catch(IOException e){
    //something sensible here
    finally{
    if(fs!=null){
    try{
    fs.close();
    catch(IOException f){
    return result;
    Once compiled you could invoke it as java MyApp c:\myInts.txt
    Sorry if there are typos in there, I don't have an ide open ;->

  • My user name and pass word have not changed  I can't get into my gmail

    My user name and pass word have not changed  I can't get into my gmail

    Can you access the email on a computer using a web browser meaning are you sure it is not a problem on the gmail end?

  • [svn:osmf:] 14474: Adding a 'dispatchInitialChangeEvent' parameter to the ' watch' method in order to allow the initial change event from being dispatched, continued.

    Revision: 14474
    Revision: 14474
    Author:   [email protected]
    Date:     2010-02-28 23:53:31 -0800 (Sun, 28 Feb 2010)
    Log Message:
    Adding a 'dispatchInitialChangeEvent' parameter to the 'watch' method in order to allow the initial change event from being dispatched, continued.
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/metadata/MetadataWatcher.as

    *Feedback*
    "Use the form below to send us your comments. We read all feedback carefully, but please note that we cannot respond to the comments you submit."
    http://www.apple.com/feedback/ipad.html
    We can complain about Apple's business decisions, but these discussions are user to user talk about possible solutions.
    Here are the places to report bugs:
    Get an account at
    http://developer.apple.com/  then submit a bug report to http://bugreporter.apple.com/
    Once on the bugreporter page,
       -- click on New icon
       -- See if you need to attach a log file or log files, clicking on Show instructions for gathering logs.  Scroll down to find the area or application that matches the problem.
       -- etc.

  • [svn:osmf:] 14473: Adding a 'dispatchInitialChangeEvent' parameter to the ' watch' method in order to allow the initial change event from being dispatched.

    Revision: 14473
    Revision: 14473
    Author:   [email protected]
    Date:     2010-02-28 23:45:28 -0800 (Sun, 28 Feb 2010)
    Log Message:
    Adding a 'dispatchInitialChangeEvent' parameter to the 'watch' method in order to allow the initial change event from being dispatched.
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/metadata/MetadataWatcher.as

    Perhaps you're not handling the "EndOfStreamEvent" correctly/at all, and thus not freeing up the socket to listen for the "NewReceiveStreamEvent " after the initial stream has ended...
    ?

  • Pass an arrayList into a method

    I am looking to pass and  arraylist into a method and I am wondering how this is done...

    I figured it out:
    public function someMethod(someArray:ArrayList){}
    I figured it was the same.
    This is dealing with flex, How ever on the AS side, so its a pure AS question

  • How do u pass an object into a method

    I want to create a method getData that takes an object of type Helper and returns an object of the same type.
    how do u pass objects into a method and how do u get objects as returns im a bit confused

    That will just allow you to pass a parameter. If you want to return a helper object
    Helper paramHelper = new Helper();
    Helper someHelper = callMethod(paramHelper);
    public Helper callMethod(Helper hobj) {
        //<some code>
        Helper retHelper = new Helper();
        //<blah, blah>
        return retHelper;

  • Scan To Network Folder Fails Post Install of Firmware Due To Password No Longer Being Passed

    The scan to network folder has been working for over a year on my OfficeJet Pro 8600 Plus to a file share in a QNAP NAS. HP CLP1CN1435AR firmware was applied to the printer in Dec 2014. Upon my first need to use the scan to network folder feature in 2015 I find that it no longer works. Attempts to validate the once working scan setup failed. Though a variety of tests I have determined that the password entered into the web server on the printer is NOT being passed as part of the logon credentials to the QNAP.
    I tested every possible combination going back to ground zero and starting fresh with multiple new user ids, passwords, network shares, 8 character user names, simple passwords, IP or hostnames in the network path, requiring SSL or not, etc. With each test, I validated that I could sign on directly to the NAS and that the user ID was authorized to change files in the network share. With each fail, I validated the logs in the router and in the NAS that traffic looked normal and it was the sign on credentials were the reason the NAS rejected the sign on. The only thing that worked was a guest ID from the NAS which does not HAVE a password. Any requirement for a password during the sign on to the NAS will not be honored or satisfied by the new firmware.
    This is an egregious error - something that should have never made it out of even the first level of testing within HP. I would love to inform HP about this discovery but alas, my printer is 2 DAYS out of warranty so the forum is well the only voice with HP that I have.
    Now I have to set up an unprotected area of my NAS by giving the gest account access which means that anyone who plugs a network cable behind my firewall gets to see the scanned information. Now I am very sorry I applied the firmware. Now I am getting to be sorry that I bought this and another HP printer despite being a customer for years.
    I would love some help from HP but not going to put out for an extended warranty or pay for phone support for something that I have easily and clearly tested to be a problem with the new firmware.
    If anyone has figured a way around this, please let me know. Hopefully it will help focus someone else who is experiencing the same problem. Network configurations can differ, ect but I am pretty sure the rash of posts in the last couple of months about the scan to network folder feature have the fail to pass the password error as the root cause.
    Unhappily & insecurely scanning to a very public folder share until then. Information that is vulnerable regardless of how brief of a moment until it is moved off the share is still vulnerable information. It’s not something I can live with for the long term.

    Hi @Road_Trip ,
    I have brought your issue to the attention of an appropriate team within HP. They will likely request information from you in order to look up your case details or product serial number. Please look for a private message from an identified HP contact. Additionally, keep in mind not to publically post ( serial numbers and case details).
    If you are unfamiliar with how the Forum's private message capability works, you can learn about that here.
    Regards,
    George
    I work for HP

  • How do i see which parameters are being passed to wwv_flow.accept?

    Greetings everyone,
    After submiting a page i get this error:
    "The requested URL /pls/apex/wwv_flow.accept was not found on this server."
    I placed some inserts inside my page process to check and i found out the process isn t even being executed.
    This post seems to have some similarities to what is happening to me:
    doSubmit in javascript
    But all the items i need to change are being changed with javascript in the same page, after submiting they get the new values.
    What gets weirder is that it works properly in firefox and google chrome browser, however it is company politics that all aplications work in internet explorer and in internet explorer it doesn't work.
    So i would like to know how to see what is being passed to wwv_flow.accept so i can discard that option?
    Regards Pedro

    Greetings,
    I am working with Pedro Mendez in the same project.
    To give you more information about the problem, here is an example of the html structure in the page, just the div wich is causing problems:
    <div id="empresas">
    <form id="empresas_form" method="POST" action="" name="empresas_form">
    <input type="checkbox" name="empresas" value="DEMO2"/>
    Empresa Demonstração ( Demo 2)
    <input type="checkbox" name="empresas" value="SPA"/>
    SPA
    <input type="checkbox" name="empresas" value="GRH2"/>
    GRH2 - Brodheim
    <input type="checkbox" name="empresas" value="DEMO3"/>
    DEMO3 DEMONSTRAÇÂO
    <input type="checkbox" name="empresas" value="GRH"/>
    GRH - IMO
    <input type="checkbox" name="empresas" value="OK"/>
    OK
    <input type="checkbox" name="empresas" value="VALSAN"/>
    Valentim Santos
    </form>
    </div>
    To my understanding the variable that shoudl cause problems would be empresas_form and not empresas, since empresas is just a div.
    I need the checkboxes to be inside a form or i can t access them and i need to perform operations on them, any suggestions?
    best regards

  • Help with passing values to methods

      GregorianCalendar baseTime = new GregorianCalendar();
      long baseSystemTime = System.currentTimeMillis();
      // After some iterations I want to update the
      // calendar to reflect the current time.
      // I do not want to go through instantiating a new calendar
      baseTime = updateTimestamp(baseTime,baseSystemTime);
      private static GregorianCalendar updateTimestamp(GregorianCalendar GC, long lastTime){
        // This gets the difference between the last time check and now.
        // It then adds that difference to the calendar and returns the updated
        // calendar.
        int msDifference =
          new Long(System.currentTimeMillis() - lastTime).intValue();
        GC.add(GregorianCalendar.MILLISECOND,msDifference);
        lastTime = new Long(System.currentTimeMillis()).longValue();
        return GC;
      }The problem is that the lastTime variable that it passed gets updated to the current MS value. But, the original baseSystemTime never changes.
    I thought that if you pass something to a method and it gets altered in the method the original object is updated. Am I wrong?

    So objects are passed by reference but primitives are
    passed by value?Simply speaking: Yes.
    Strictly speaking: No. Every parameter is passed by value because Object obj IS a reference. So when you do call(myObject), you are passing the value of the reference of the object (the adress of the object).

  • Error : passing parameters from method to FM is empty ?

    Hello,
    import parameters are not being passed to the end ???
    i have a workflow with a task, this task is calling a method called METHOD1 and this method is linked to a function module FM1.
    The workflow is triggered by an even, so i did binding between the event container and the workflow container, and then between the workflow container and the task container, so METHOD1 has import parameters.
    when i debug, the values of the import parameters are in the source code of the program under SWO1 but when from there the system calls FM1 prviding the correct import parameters for FM1, the parameters are not reaching, when debugging FM1 i see that its import parameters are empty.
    Any ideas as to why this is happening ?
    points are awarded.
    Regards

    Hello,
    thanks for your answers.
    Still did not work. Here is what i have:
    the workflow is triggered by the even "changed"
    so i am binding the object key from the event container to the workflow container, and then from the workflow container to the task container. the task takes a method that has import parameters, these import parameters are the keys of the object  that created the event. So when the task is calling the method, the import parameters have values, then this method exports these parameters to the function module, the function module have import interface, in the function module, the parameters are reaching empty, but when i am in the method the parameters have values. so why i am loosing these values once the method calls the function module.
    I tried doing pass by reference and pass by value -> did not work.
    - Yes i made sure that they are of the same types
    - what is SWC_GET_ELEMENT CONTAINER  and why should i use it -> No i am not using it.
    -the variables that i defined in the workflow container are set as , import, export and mandatory. - > is this correct ? i tried import and mandatory but this too did not work.
    Can you guys please provide me with more insight as to why this is happening ?
    regards
    points are awarded.

  • Is it possible to find an instance of an object without it being passed to

    Hi all,
    I have a parser class "MessageParser" which i pass a message which is of type "String" to it for it to be parsed. The parsing method signature for the class is
    public void parse(String message);
    I need to pass an instance of "Properties" to it but i dont want to change the signature of the method to add a new argument to it. I have been struggling with this for the last couple of days and have tried a couple of options - see http://stackoverflow.com/questions/5134462/sending-in-an-object-of-type-object-instead-of-string-polymorphism
    The class that calls the parsing method "ParserManager" knows of the properties object. Is there a way for the MessageParser to find the properties object without it being passed to it?
    Thanks
    ps - also posted in http://stackoverflow.com/questions/5140795/is-it-possible-to-find-an-instance-of-an-object-without-it-being-passed-to-the-me

    ziggy wrote:
    I need to pass an instance of "Properties" to it but i dont want to change the signature of the method to add a new argument to it. I have been struggling with this for the last couple of days and have tried a couple of options - see http://stackoverflow.com/questions/5134462/sending-in-an-object-of-type-object-instead-of-string-polymorphism
    The class that calls the parsing method "ParserManager" knows of the properties object. Is there a way for the MessageParser to find the properties object without it being passed to it?I completely agree with Kayaman if you can get away with only the passing the Properties once (as he suggests, at construction time).
    If you can't (ie, you must pass the Properties with each message), then I suspect you have a new type of Parser, and your design will have to reflect that.
    One possibility would be to extend Parser with a PropertiesParser interface that defines a new parse() method and either update the current ParserManager to "understand" the difference, or create a new one.
    The problem with the first option is that the manager then becomes a dispatcher, which kind of goes against the grain of OO programming (what if you need to add a third type of parser, or a fourth?).
    Another possibility (probably better) would be to create a variant of your MessageObject class that includes Properties, and a variant of your MessageCParser that knows how to deal with such an object.
    There are many ways to go, and only you probably know which is best.
    That said, if you can get away with passing the Properties once, definitely follow Kayaman's advice.
    Winston

Maybe you are looking for

  • Connecting USB HD to TC; to use on Mac and Windows

    Hi, I've been trawling through the discussions/support sections and I can't seem to find a solution to what can't be a rare a problem. I have a USB Hard Drive that I want to use to transfer some stuff of my TC to a Windows computer. I've plugged it i

  • Error when assigning SID

    Hello Gurus, I have created a characteristic infoobject(ZCSHIPTYP) for Shipment type and included the same in the ODS. When I load data, during activation it gives the foll error :- By default, only the following standard characters are valid in  cha

  • Why does iphoto not copy all photos when transfering

    Hi peeps. why does iPhoto not copy all photos from an event when im copy/pasting to an external folder on my mac(for later transfer). All softwares are up to date and ive only just realised it happens, but when i copy all pics in an event then paste

  • Get error msg when opening iphoto from Photoshop: "Open iphoto 5 or later..

    I get an error msg when trying to open a photo in iPhoto from Photoshop: "Open iPhoto 5 or later to see photos from your iPhoto Library in this list." ... but in info it says I have iPhoto '08.... I am confused.... what is iPhoto 5, and how is it dif

  • Why does my Firefox freeze when I open my news feed on Facebook?

    For a few days now, everytime I go to my news feed on Facebook, Firefox freezes and I have to force it to stop. This means everytime I click on the Facebook logo or go to www.facebook.com. I have already reinitialised Firefox, but that doesn't help t