How to retrieve List contents?

Yes! I've searched the forum already, but I see no clear answer or maybe it's just that I'm new to Java and can't quite understand everything...
Somewhere on the application a List is filled with data. Now say I want to print the contents of this List, (not the object reference), how do I do it? I know how to loop it with hasNext and stuff, but I don't know how to view its real data! Is there a simple way to do it?
I've tried using methods like Iterator, listIterator, toString, get etc... but no joy :(
I don't even know if that's how it's done! Please help! Thanks in advance

List myList = new ArrayList();
myList.add("Hello");
myList.add("World!");
for(Object o : myList) {
System.out.println(o.toString());
}A couple of side note on the above in case the OP sees it:
The toString() call on 'o' is redundant, as println(Object) will implicitly invoke the toString() method on the parameter.
To just print the contents of a List, it would be more simple to just do:
System.out.println(myList);
Again, the toString() method is implicitly invoked (on the ArrayList object in this case), which is implemented to iterate over itself, returning a String containing each element's toString().

Similar Messages

  • How do retrieve the contents from a DataTable?

    I have a DataTable filled with the contents of an Excel spreadsheet. 
        DataTable dtDataTable = new DataTable();
        using (OleDbDataAdapter oledbAdapter = new OleDbDataAdapter(oledbCmd))
            oledbAdapter.Fill(dtDataTable);
    How do retrieve the contents from the DataTable? ... one value at a time (for example row 3, column 5).
    bhs67

    This works:           
        string stData = dtDataTable.Rows[3].ItemArray[5].ToString();
    bhs67

  • How to retrieve the content of the indexed column

    In Oracle UltraSearch, how to retrieve the content of the file in the indexed column cache_file_path.
    we try the flowing sql
    SELECT cache_file_path FROM mytable
    WHERE contains (mytable.cache_file_path, 'viet', 1) > 0
    but we only have the cache_file_path column, not the content of the file were indexed.

    I think this is what you're looking for:
    DECLARE @table TABLE (amountPaid FLOAT, datePaid DATE, memberID INT)
    INSERT INTO @table (amountPaid, datePaid, memberID) VALUES
    (10.00, '2014-01-01',1),(10.00, '2014-02-01',2),(10.00, '2014-03-01',3),(10.00, '2014-04-01',4),(10.00, '2014-05-01',5),(10.00, '2014-06-01',6),(10.00, '2014-07-01',7),(10.00, '2014-08-01',8),(10.00, '2014-01-01',9),(10.00, '2014-10-01',10)
    SELECT *
    FROM (
    SELECT *, SUM(amountPaid) OVER (ORDER BY datePaid ROWS UNBOUNDED PRECEDING) AS runningTotal, ((SELECT SUM(amountPaid) FROM @table) / 100) * 50 AS percentileAmount
    FROM @table
    ) x
    WHERE percentileAmount >= runningTotal
    It depends upon SQL Server 2012's windowed functions. It would be possible to also do this with a rCTE in earlier versions.
    Giving your code an eyball, I think I see what it's doing. Unfortunately, I'm stuck using 2008 R2, so I don't have access to UNBOUNDED or PRECEDING. I'll have to research rCTE - I know what a CTE is, but not the 'r' prefix.

  • How to retrieve the content type used in a document library (C# - Client Model).

    Hello,
    I need to know if it's possible to retrieve the content type used in a document library, so I can know the columns active and used in this document library. I am using the Client Model in C#.
    Thanks

    First, retrieve your document library as a List object. Then, use the
    List.ContentTypes property to iterate through all the content types assigned to the list.
    Blog:
    blog.beckybertram.com |
    RSS | @beckybertram |
    SharePoint 2010: Six-in-One

  • How to retrieve music content from iCloud

    Hello,
    My main computer crashed (hard drive died), & so I have been backing everything up to iCloud.  I would like to know how I can retrieve the contents of my music (on iTunes) to my new computer without losing everything.  Also, while I have your attention.....does anybody know how to delete previously authorized computers?
    Many thanks!

    Welcome to the Apple Community.
    You can't back up from a Mac to iCloud, what makes you think you have.

  • How to retrieve list of iviews in a folder in pcd through webdynpro -- ASAP

    Hello,
    The requirement is to build an application in webdynpro which can retrieve the names of the iviews present in a specific folder.
    Can anyone help me out in this regard as to how to approach.
    Thanks
    *points are rewarded

    Hi,
    Here is the excellent document / blog written by one of my colleague. i hope with this you will solve you issues
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401
    oh... sorry.... but its not using Web dynpro.
    check this
    Retreive a list of workets, iViews, pages from Roles
    regards,
    Pradeep
    Edited by: pradeep bondla on Jul 15, 2008 6:52 AM

  • How to retrieving the content using Links

    Hi
    Please suggest me how to retrive content using link property.
    I have added link property to my Content. and i have added in internal resource path to the Link property.
    But my question is how access the page which is linked to my Content.
    How can i use it with anchor tag when i want show display the linked page content.
    what are tags to be used to retrive the linked content in the page.
    I found below line in CM documentation
    "These relationships are used by developers in their content queries when retrieving content to display in
    your portal."
    But i could found how to retrive.
    Genarally what technique we use to link an internal resource of our Content management
    thanks in advance
    Edited by: vamshi krishna on Jun 12, 2011 12:32 AM

    It sounds like there may be a misunderstanding about our link property feature.
    That feature is not for web hyperlinks. For that you can just use a string property. The links feature is for pointers to other pieces of content.
    (from: http://download.oracle.com/docs/cd/E13155_01/wlp/docs103/cm/contentTypesCm.html)
    "Using Link Properties
    You can create properties that allow content contributors to associate content items. Content contributors can link to content within the same or different repositories within the Virtual Content Repository. For example, if you have related content items that are stored in different folders, you can use content link properties to create relationships among content items. These relationships are used by developers in their content queries when retrieving content to display in your portal.
    Link properties can also be multi-valued to allow content contributors to link to multiple content items. For detailed instructions on adding a link property, see Define the Properties of a Content Type."
    Edited by: Chris Bales on Jun 13, 2011 2:56 PM

  • How to retrieve preloaded content?

    I recently received a 16 GB iPod Touch from Subaru when purchasing a new car with them. The iPod came preloaded with some videos and photos. When I connected the iPod, iTunes said that the iPod was sync'd with another computer and that I would have to remove all the content before I could add my own content.
    What I'd like to know is, can I retrieve the preloaded content that Subaru put on the iPod?
    Thanks,
    Eric

    Thank you for your reply fanciscoandre, unfortunately, the article does not seem to have helped, so I'll be trying the other apps shortly. :/
    Here's a brief update:
    When I connect my iPod, I see the following prompt (note, I have named my iPod "tactile").
    http://www.xmtp.net/~encoded/img/tactile/pre-loaded/Picture%201.png
    I have so far, always clicked "No".
    This prompt differs from what is mentioned in the article you sent. The article does list a few other ways to "Transfer Purchases" from the iPod, so I tried both of them (command-clicking on the ipod in the devices list, and also selectin "Transfer Purchases" from the File menu. Neither appeared to do anything at all..? No dialog, no noticeable actions taken.
    Most recently, when I connected my iPod, the prompt above was followed by this new prompt, which may or may not be related to the first prompt (or anything else in this post). I had not seen this prompt before now.
    http://www.xmtp.net/~encoded/img/tactile/pre-loaded/Picture%202.png
    I did send this information to Apple.
    I will check out the other apps you mentioned now though, since the first route didn't work.

  • How to retrieve sharepoint list data and show it on excel-addin using C#

    Hi,
    we have a sharepoint list where all students are present. we wanted to get the data from the list and show it via excel addin (VSTO) (something like save,retrieve buutons) . we have some more business logic which need to be performed before the data is retrieved
    . once data is shown on excel , user modifies it and update/save the record back to sharepoint.
    can you please give some samples and suggest any links to start with development.
    Thanks
    chaitu

    Hi chaituatp,
    For this requirement, I would suggest you to get familiar with how to create VSTO applications, and how SharePoint object model works. Here are some sample code about this:
    How to: Retrieve List Items using JavaScript:
    http://msdn.microsoft.com/en-us/library/hh185007(v=office.14).aspx
    http://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx
    VSTO application show data in datagridview:
    http://stackoverflow.com/questions/16926275/simple-example-of-vsto-excel-using-a-worksheet-as-a-datasource
    Thanks,
    Qiao
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Qiao Wei
    TechNet Community Support

  • Retrieve the content of the file in the indexed column

    In Oracle UltraSearch, how to retrieve the content of the file in the indexed colun cache_file_path.
    we try the flowing sql
    SELECT cache_file_path FROM mytable
    WHERE contains (mytable.cache_file_path, 'viet', 1) > 0
    but we only have the cache_file_path column, not the content of the file were indexed.

    Please post on the UltraSearch forum.

  • Does anyone know how to retrieve lost mailbox folders and their contents in mail?

    Does anyone know how to retrieve lost mailbox folders and their contents in mail?

    It might be that you selected "Delete sent mail after a mont (or a week, or whatever)" in Mail Preferences. iCloud account is IMAP, so it won't keep mail in your HD. I have that problem.

  • How to retrieve configuration list for WebDynpro component

    Hi experts,
    I have webdynpro component A with configuration AA.
    How to retrieve configurtion AA ? Is there any interface or Function module I can use?
    Also another question is how to get webdynpro configuration of WebDynpro application.
    Thanks.
    best regards,
    Vincent

    Hi Abhi,
    Yes , this is possible.
    But I want to get configuration dynamically.
    Input parameter : WebDynpro compoenent name
    Output Parameter: List of WebDynpro Configuration
    Is this possible?
    Vincent

  • I lost my iPhone5 data when restoring with my iphone4 contents, how to retrieve it?

    I lost my iphone5 data when restoring with my iphone4 contents, how to retrieve it?

    Unless you have a backup of the iPhone 5 data you lost, it's gone.

  • How to retrieve datas from database to dropdown list in jsp

    hai.
    please tell me how to retrieve a perticular field list from database to a drop down list using jsp. i am new to jsp. i am doing employee management system. in that i need to edit employee's details as like.
    so that i want to display employee id's in a drop down list. i want to retrieve from database and display.
    please help me in this .
    advance thanks.

    Hello friendz,
    If tht is the i wud suggest if guyz can go wid AJAX...
    try to make use of xmlHttp Object and generate a new dependent drop down by using a property from a bean->servlet->VIEW(FORM)
    else save the form state in a session and then refersh it. once all in again.
    i had a similar problem which i solved in the following way
    Hi friend,
    I had a similar situation and i tried to solve it by using XmlHttpRequest Object(used in AJAX).
    U can checkout the below example just for further reference delete
    UserForm.jsp:
    ==========
    <head>
    <script>
    var xmlHttp
    function showState(str)
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    alert ("Browser does not support HTTP Request")
    return
    var url="getState.jsp"
    url=url+"?count="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChange
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    function stateChange()
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById("state").innerHTML=xmlHttp.responseText
    </head>
    <body>
    <select name='country' onchange="showState(this.value)">
    <option value='india>india</option>
    </select>
    <br>
    <div id='state'>
    <select name='state' >
    <option value='-1'>pickone</option>
    </select>
    </div>
    </body>       
    getState.jsp
    ============
    <%@page language="java" import ="java.util.Hashtable" import ="java.util.Set" %>
    <%
    String country=request.getParameter("count");
    response.setContentType("text/html");
    response.setHeader("Cache-Control","no-cache");
    try{
    Hashtable ht = (Hashtable)session.getAttribute("<ATTRIBUTE_NAME>");
    String buffer="<select name='state'><option value='-1'>Pick One</option>";
    Set s=ht.keySet();
    Object keys[]=s.toArray();
    int size=keys.length;
    for(int i=0; i < size;i++){
    buffer=buffer+"<option value='"+ht.get(keys).toString()+"'>"+ht.get(keys).toString()+"</option>";
    buffer=buffer+"</select>";
    response.getWriter().println(buffer);
    catch(Exception exp){
    response.getWriter().println(exp);
    %>

  • How to retrieve Task Lists from All Subsites to the Parent Site and display in Grid view using CAML Query

    How to retrieve Task Lists from All Subsites to the Parent Site and display in  Grid view using CAML Query + object model

    do u just want task list or items under task list for all subsites
    for items use spsitedataquery ref
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx use recursive to get it from alll subsite under site collection
    for tasklist only u can a simply use a for loop to find in all subsite
    Manish Sati

Maybe you are looking for

  • Buttons disappear

    Hi all, I'm sorry, I'm not sure if my problem relates to some of the other postings I've read on the forum or if it's something else I'm not aware of but the problem is this: I display a JFrame with a few JButtons for different options, like a menu o

  • How can i unlocked iphone 4

    How can i unlocked my iphone4 for use outside u.s.

  • GarageBand 3: Rewire fails on Intel Mac

    I tried to connect GarageBand 3.0.2 and Reason 3.0.5 via ReWire. No success. Transport and sync is working and Reason says that it is in ReWire Slave Mode. So far everything seems to be OK. Unfortunately, there is no audio output from Reason. This ha

  • Importing & Burning Folder Issue

    I've had iTunes on my PC for a few years now, but I have just noticed that something has changed: My iTunes library is located at C:\users\myusername\Music\ . ITunes is set up to use this path when importing new media. However, when I add new media,

  • Folders under "Photos" on iPod?

    I sync my iPhoto Library with my iPod nano, and it works well. In iPhoto, I have organized all my photos in albums inside folders. I have a huge amount og albums which lay in different folders in the iPhoto source list. BUT: When I transfer the photo