File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Returning array from bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Returning array from bean" Watch "Returning array from bean" New topic
Author

Returning array from bean

smita khot
Greenhorn

Joined: Dec 08, 2008
Posts: 1
Hello All,

I want to return array from getter methods of my bean, but findbugs show error as "may expose internal representation". what is the resolution for it? how should i return array from my bean class?
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Either you can ignore the warning or you can create an identical local array, copy all values over then return the new array.
You only want to do it if you really want to restrict user from manipulating your array (internal state) indirectly (i.e. not via your object method, but to get the array, and manipulate its values hence your internal array changes accordingly).


“Everything should be as simple as it is, but not simpler.” Albert Einstein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning array from bean
 
Similar Threads
Newbie Q: ok to pass ResultSet from bean to JSP?
returning an array
Array of bean objects
How can I return Stream from Session bean ????
Passing an array back from Javabean to JSP