CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    11

    pass reference to method

    I'd like to initialize 2 parameter in a method, in C++, I can do like this:

    void setParam(int* width, int* height)
    {
    *width = getWidth();
    *height = getHeight();
    }
    int w, h;
    setParam(&w, &h);




    How Can I do this in Java?


  2. #2
    Join Date
    Dec 1999
    Posts
    23

    Re: pass reference to method

    All objects in Java are passed by reference, but not primitives.
    If you wan't to pass an integer by reference put the int in a class like java.lang.Integer

    example:
    Integer i = new Integer(1);
    method(i);

    public void method(Integer integer)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured