How to access last object in a Collection.

Hello. I'm trying to figure out how to access the last element in a collection. This is how I have it coded now:
Collection coll = someMethodThatReturnsACollectionOfMyTypes( );
Iterator It = coll.iterator( );
MyType myType = null;
while ( It.hasNext( ) )
myType = ( MyType) It.next( );
At this point myType should reference the object I'm interested in, but there has to be an easier way. Any suggestions would be greatly appreciated.
-Jason

Containers either are or aren't expected to support random access, depending on the container. For those containers that do support it, like ArrayList, you can do the following:
public Object getLast(AbstractList a) {
  if (0==a.size()) return null;
  return a.get(a.size()-1);
}

Similar Messages

  • How to access Business Objects Explorer?

    I am new to Business Objects and would like to know how to access Business Objects Explorer from my local system. I have Business Objects XI 3.1 installed on my system.
    I would like to know if BO explorer requires a separate installation package? If yes, how can I acquire it?
    If No, what are the steps to integrate the BO Server with the BO explorer?
    Edited by: Bhavani I on Jan 28, 2010 11:23 AM

    Hi,
      You can refer to the below link for more details on BO EXplorer,
    https://cw.sdn.sap.com/cw/servlet/JiveServlet/previewBody/119973-102-1-220562/BO%20Explorer%20Implementation%20checklist.pdf
    Regards,
    Balajee
    Edited by: Balajee Sivakumar on Apr 27, 2011 6:30 PM

  • How to access an object in a bean

    I am looking for a way to access an object in a bean and make available to the page.
    for example if i have a Bean called User and it contains an attribute Called Company as an attribute in User. Now I have User.getCompany(). and I can do this
    <%User user = request.getUser();
    Company company = user.getCompany();
    request.setAttribute("comp", company); %>
    how do I do this with useBean ?

    I am looking for a way to access an object in a bean
    and make available to the page.
    for example if i have a Bean called User and it
    contains an attribute Called Company as an attribute
    in User. Now I have User.getCompany(). and I can do
    this
    <%User user = request.getUser();
    Company company = user.getCompany();
    request.setAttribute("comp", company); %>
    how do I do this with useBean ?You can access a JavaBean Object property of another JavaBean inside the JSP with the use of EL (Expression Language)
    So if you are using JSP 2.0 or higher try this:
    <jsp:useBean id="user" class="your.package.User" scope="request"/>
    ${user.company.id}I tested the above and it works.
    Note that you need to set the Company object in the User object before trying to access it inside the JSP.
    You can also set it in the JSP if you want, (before trying to access it), but its cleaner to do it in a Servlet.
    Both User and Company must follow JavaBeans notation.
    So in the above case the User object is something like this:
    package your.package;
    public class User{
       private Customer customer;
       public User(){}
       public Customer getCustomer(){
          return customer;
       public void setCustomer(Customer customer){
         this.customer = customer;
    }And your Customer JavaBean is something like this:
    package your.package;
    public class Customer{
       private int id;
       public Customer(){}
       public int getId(){
         return this.id;
       public void setId(int id){
         this.id = id;
    }

  • ListCellFactory - how to access an object's data associated with list cell?

    I am new to javafx and building a sample app to learn the basics. The app has a list view control and used listcellfactory to create listcells. Each list cell is composed of few labels and image. I populated list view with listViewItems function, where in it sends object[]; I have my own object with data that needs to be populated in the list cell. I have hard coded the object[] and that size is reflected in list view items size. However, I am not able to populate the object data in individual labels.
    In the following code, I can only get the string representation of the object and I am unable to figure out how to individually access the object's data. Please help me with this.
    function listCellFactory(): javafx.scene.control.ListCell {
    var listCell: javafx.scene.control.ListCell;
    def offerLbl: javafx.scene.control.Label = javafx.scene.control.Label {
    text: bind "{listCell.item}"
    def descriptionLbl: javafx.scene.control.Label = javafx.scene.control.Label {
    text: bind "{listCell.item}"
    def friendLbl: javafx.scene.control.Label = javafx.scene.control.Label {
    text: bind "{listCell.item}"
    def offerImgView: javafx.scene.image.ImageView = javafx.scene.image.ImageView {
    image: imagetrial
    fitWidth: 300.0
    fitHeight: 250.0
    def offerVerticalBox: javafx.scene.layout.VBox = javafx.scene.layout.VBox {
    content: [ offerLbl, descriptionLbl, friendLbl, offerImgView, ]
    spacing: 6.0
    listCell = javafx.scene.control.ListCell {
    node: offerVerticalBox
    return listCell
    }

    If I understand you question, it should be (listCell.data as YourClassName)
    Edited by: AigarsP on Oct 21, 2010 2:10 PM

  • How to pass Custom object embedded in Collection

    Hi,
    I'm building an J2EE application(Weblogic 7.0) with swing Client. Our requirement
    is to add custom objects in a Collection and return it to Client thru web service.
    I dont know how to write build.xml so that ant utility created its own parser
    file for the cutom object. We may have lots of custom objects . These objects
    are being returned by a generic response object . I mean a Collection may conatin
    different custom objects depending upon context. This Collection is embedded in
    the generic response object. Can anybode help me to write a buil.xml for this.
    Please suggest a best solution.
    thanks
    Jobinesh

    Contd.......I forgot to mention one thing. We are supposed to use StatelessSessionBean
    as front controller. In this context we can use the ant task for converting this
    front controller to web service.
    Pls help me....
    "jobinesh" <[email protected]> wrote:
    >
    Hi,
    I'm building an J2EE application(Weblogic 7.0) with swing Client. Our
    requirement
    is to add custom objects in a Collection and return it to Client thru
    web service.
    I dont know how to write build.xml so that ant utility created its own
    parser
    file for the cutom object. We may have lots of custom objects . These
    objects
    are being returned by a generic response object . I mean a Collection
    may conatin
    different custom objects depending upon context. This Collection is embedded
    in
    the generic response object. Can anybode help me to write a buil.xml
    for this.
    Please suggest a best solution.
    thanks
    Jobinesh

  • How to access Captivate Objects From Widget

    Using the widget factory, is there a way to access a specific property such as a button or textbox in a captivate movie from an widget?
    The button in captviate does have an instance name called button_mc. In my widget, I do have
    myRoot = MovieClip(root);
    mainMov = MovieClip(myRoot.parent.root);
    Also, how can you get the slide properties such as total frames?
    Can't seem to find out how or I am just missing something
    Thanks

    Hi Ukie,
    Here's an article on how to access objects on the Captivate slide with WidgetFactory: http://www.infosemantics.com.au/widgetking/2010/10/slip-sliding-away/
    In short, pass in the instance name of the button into the getSlideObjectByName() method:
    var myButton:Sprite = getSlideObjectByName("button_mc");
    Also, WidgetFactory has a property widgetSlide wich gives you access to the slide that the Captivate Author placed the widget on. This is a MovieClip, so if you wanted to read its total frames, you'd write:
    widgetSlide.totalFrames;
    Hope that answers your questions.

  • How to access COM+ Objects From JSP

    Friends,
    We have a requirement to access COM+ objects from JSP. Please guide me on this.
    Thanks in advance.
    Tarani

    Sanyam wrote:
    if there is any .dll extension file, how can we read that file in labview?
    You can use Call Library Function node to call that dll file and use it in LabVIEW. Read the help and you will get more details.

  • How to access Business object type attribute from a method/function modul ?

    Hello,
    i have created a business object type object along with attributes and methods. Now inside the method i want to access the attributes. inside the method i am writing:
    data a type XXX.
    a = me->attribute
    this is creating a compilation error.
    Now the method is defined as a function module in some package, so can anyone inform me how to access object attributes from the function module ?
    pointes are awarded
    Regards

    Hello,
    thanks for your answer, but this too did not work, "=>" is for static attributes and the attributes i have are not static. Moreover, i tried it but it gave the same error :
    the abap error was when i was checking the code is :
    the type me=>documenttype is unknown
    as you know in SWO1 i created an object and when i create a method you link it to a function module and this is where you have the implementation of the method, so from this method how can i access the attributes on the main object that i created in SWO1
    regards

  • How to access an object's variable from native code

    i am passing an object in a native method.i have to change the value of the object's variable.how do i access the variable of object and assign it new value from c++ code.when i try to access it i get a message that the variable must have a class/sruct/union type.
    pl. help.

    I'll tell You if You send me the structure of this object in Java. And a name of field what are You thinking about.
    Maciek

  • How to link 2 objects and how to access entities objects

    Hi,
    I have 2 tables "Person" and "Adress". Person has a foreign key to Adress. The tables have a primary key (person_id and adress_id) associated with a sequence table. I use entites objects from tables and i defined a creation form for "Person" and a creation form for "Adress".
    While the commit, i would like to link person with adress via the foreign key. So i don't know how to obtain "adress_id" from the entity object for setting the foreign key in the object "person".
    More, how can i access to the entites objects for accessing information via getter methods.
    Thank for your help.

    Hi,
    documented in http://download-uk.oracle.com/docs/html/B25947_01/toc.htm it is explained in http://download-uk.oracle.com/docs/html/B25947_01/bcentities008.htm#sthref464
    Exactly the same question got answered yesterday: Re: How I can acess to master entity object from detail entity object
    Frank

  • How to access ServletContext object of a webapp on remote server?

    Hi!
    I have a webapp, runs on tomcat, loads information from local db server, keeps them in servlet context, and publish these datas to web via jsp pages.
    I make run the same webapp on different location, different webserver and db server with different datas.
    Is it possible to link both ServletContext to each other, or access one from the another?
    What is the right solution, if I want to access all stored Objects of these independent webapplications, summarize and show them in one browser page, in one jsp?
    sorry for my poor english
    and thanks for any help,
    kind regards,
    henpanta

    It is not possible to access another servletcontext glueless using HTTP or any transfer protocol. Would be a potential security hole too. If you want to let communicate 2 webapps on different servers with each other, consider webservices.

  • How to access custom object as property in yField

    Hi All,
    I have a stacked column chart. The data provider (dp) has an
    array of object DataObject which has array of custom objects of
    class ClientRev:
    public function ClientRev(name: String, rev : Number)
    cName = name;
    cRev = rev;
    // data provider
    public class DataObject
    public var clientRev : Array;
    Now I have to use cRev property of clientRev elements of
    DataObject (DataObjects makes data provider) in yField of
    ColumnSeries.
    if i write,
    yField="{clientRev[0].cRev}",
    It doesn't work. Please lemme know how can I achieve my goal.
    Thanks for help.

    "vaibhav.chauhan" <[email protected]> wrote
    in message
    news:gdmhok$2eq$[email protected]..
    > Hi All,
    > I have a stacked column chart. The data provider (dp)
    has an array of
    > object
    > DataObject which has array of custom objects of class
    ClientRev:
    > public function ClientRev(name: String, rev : Number)
    > {
    > cName = name;
    > cRev = rev;
    > }
    >
    > // data provider
    > public class DataObject
    > {
    > public var clientRev : Array;
    > }
    >
    > Now I have to use cRev property of clientRev elements of
    DataObject
    > (DataObjects makes data provider) in yField of
    ColumnSeries.
    >
    > if i write,
    > yField="{clientRev[0].cRev}",
    >
    > It doesn't work. Please lemme know how can I achieve my
    goal.
    Use a dataFunction

  • How to access servlet objects from OA page controller class

    Hi everybody!
    I need to put some value into servlet attribute in OA page controller class to read it from ordinary servlet later.
    How can i do it? Is it possible to get HttpServletRequest and HttpServletResponse objects from page controller?
    Thank you.

    I have a servlet which receives uploaded files with special attributes (something like tags for file) using POST request.
    This attributes created when user open page in standard OAF page via page controller.
    On client side I have an applet which uploads user selected file to my servlet and passes this file attributes.
    Now this attributes passes as plain text. I want to encrypt this attributes to hide attribute details from user. To do this I need to share some information between OAF page and my servlet.
    I know that OAF supports URL encryption, but to decrypt it I should use standard pageContext object.
    But in ordinary servlet I can't use it.

  • How to access form objects from different class?

    Hello, I am new to java and i started with netbeans 6 beta,
    when i create java form application from template i get 2 classes one ends with APP and one with VIEW,
    i put for example jTextField1 with the form designer to the form and i can manipulate it's contents easily from within it's class (let's say it is MyAppView).
    Question>
    How can i access jTextField1 value from different class that i created in the same project?
    please help. and sorry for such newbie question.
    Thanks Mike

    hmm now it says
    non static variable jTree1 can not be referenced from static context
    My code in ClasWithFormObjects is
    public static void setTreeModel (DefaultMutableTreeNode treemodel){
    jTree1.setModel(new DefaultTreeModel(treemodel));
    and in Class2 it is
    ClasWithFormObjects.setTreeModel(model);

  • How to access HttpRequest Object from Axis web service?

    Hi all,
    I have Axis web service named shoppingcartService,
    and i have ShoppingCartImpl as implemention class which
    implements passfamily() method
    When client access my web service, ShoppingCartImpl's passFamily method is executed.
    I have one more servlet under my axis web application which implements business logic.
    problem is that i want to call/invoke this servlet from passfamily method of ShopingCartImpl class.
    So how can i call/invoke servlet from passFamily method of ShoppingCartImpl class ?
    (All stuff is under Axis web application under Tomcat).

    hi
    the following link may helpful to you
    http://e-docs.bea.com/wls/docs81/webserv/anttasks.html#1111537
    Regards
    Prasanna Yalam

Maybe you are looking for

  • ISCSI connections for guests: how to set up?

    A couple of questions: 1. If we wanted to set up iSCSI connections for guests such as SQL servers, what is the best way to handle this? For example, if we had four 10-Gb NICs and wanted to use as few of them as possible, is it common to turn two of t

  • The maximum cable distance from antenna and Cisco 1200 series.

    Hello all! I?m using the Cisco 1200 Access Points Series with two 2.2dBi dipole antennas. I have read the installation guide for that Access Points and that can be installed with the antennas in separated places. But this guide didn't mention the max

  • FinalCutPro Timeline playhead jumps to begining at end of last clip?

    I want the playhead to stop playing when it reaches the end of the last clip instead of jumping back to Timeline 00:00 and continuing to play from there??

  • Third Party Remittance config for Canada

    I have a requirement as follows: Third Party Remittance programs are to be available for use by Canada. When executing program PC00_M07_K500 we get the below error message Entry notfound for wage type: /102 Business number : XXXXXXXXX and prov. of em

  • Flash 10.3.181.23 ActiveX MSI needs admin credentials to install

    I am working at a company that installs Flash through Active Directory. We have a mix of Windows XP 32-bit systems and Windows 7 64-bit systems. We are currently running Flash 10.3.181.14 and I am trying to update everyone to the newest version. The