Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-30-2007, 06:41 PM
Member
 
Join Date: Oct 2007
Posts: 2
jbostjr is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-30-2007, 11:15 PM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 112
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
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.

Code:
Person guy = new Person(); Person girl = new Person(); guy.shakeHands(girl); 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:

Code:
<%= 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 11:19 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to get my Java Bean to access a parm that I'm passing via a jsp? 72dolfan JavaServer Faces 1 03-13-2008 03:36 PM
Passing objects in Java jbostjr Advanced Java 1 10-30-2007 06:57 PM
Passing a value.. Lagarto New To Java 0 08-01-2007 05:32 PM
Passing the Values Lagarto Database 1 07-16-2007 04:03 AM
com objects in java boy22 New To Java 1 07-14-2007 07:27 PM


All times are GMT +3. The time now is 11:03 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org