Results 1 to 2 of 2
  1. #1
    jbostjr is offline Member
    Join Date
    Oct 2007
    Rep Power

    Default Passing objects in Java

    How do you pass objects in Java? By reference? If so, give an example. Also, how do you display them in a JSP?

  2. #2
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Rep Power


    Tricky question. Everything in Java is passed by value. Objects are actually never passed, only references to objects. This makes it sound like objects are passed by reference but they are NOT.

    Code wise, objects are passed like any other variable.

    Java Code:
    Person guy = new Person();
    Person girl = new Person();
    public class Person(){
        public void shakeHands(Person shakee){
    As far as JSP pages go, that's a pretty broad question. The most basic way is something like this:

    Java Code:
    <&#37;= object.toString(); %>
    I know this works for return types of Strings and ints. It might work for others but I'm not 100% sure.
    Last edited by ShoeNinja; 10-30-2007 at 10:19 PM.

Similar Threads

  1. Passing a value..
    By Lagarto in forum New To Java
    Replies: 3
    Last Post: 01-23-2011, 05:58 PM
  2. Replies: 1
    Last Post: 03-13-2008, 02:36 PM
  3. Passing objects in Java
    By jbostjr in forum Advanced Java
    Replies: 1
    Last Post: 10-30-2007, 05:57 PM
  4. Passing the Values
    By Lagarto in forum JDBC
    Replies: 1
    Last Post: 07-16-2007, 03:03 AM
  5. com objects in java
    By boy22 in forum New To Java
    Replies: 1
    Last Post: 07-14-2007, 06:27 PM

Posting Permissions

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