How to change elements in ArrayList into String

Greetings,
i like to change elements in arrayList into string.
This is how i declare an ArrayList in a Java file
ArrayList listing = new ArrayList();below is just a simple example of how i insert the string into the arraylist
String concat = "';
concat = concat + "apple";
//Transfer the concat string into arraylist
listing.add(concat);
return listing;
{code}
On my Jsp page, it will receive the ArrayList from the java file. Lets say the Arrayist is pass into my JSP arraylist
This is my JSP arraylist
{code}ArrayList optLists = new ArrayList();{code}
Inside the arraylist element, it holds data eg: *308577;;RS | [CAT 2] Level: Arena, Section: A02* with a pipe between RS and CAT 2.
Now i looping the arraylist
{code}int a = 0;
     for ( a=0; a < optLists.size(); a++)
          String tempString = "";
          String splitTemp = "";
                 String tempString = (String)optLists.get(a);
          splitTemp =  tempString.split("|");
          System.out.println("Split String Results: "+ splitTemp);
     {code}}
Heres the error:
*SeatAvailable_jsp.java:560: incompatible types*
    *[javac] found   : java.lang.String[]*
    *[javac] required: java.lang.String*
    *[javac]             splitTemp =  tempString.split("|");*
    *[javac]*       
What can i do to solve the problem?
Edited by: leeChaolan on May 2, 2008 4:45 AM
Edited by: leeChaolan on May 2, 2008 4:48 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

paternostro is right, you are returning an array into a string which is wrong
but try this, i haven't tested it though..
nt a = 0;
     for ( a=0; a < optLists.size(); a++)
          String tempString = "";
          String splitTemp = "";
                 String tempString = (String)optLists.get(a);
          String[] splitTemp =  tempString.split("|");
          for(String xyz : splitTemp)
               System.out.println("Split String Results: "+ xyz);
     }Edited by: linker on May 2, 2008 1:17 PM
Edited by: linker on May 2, 2008 1:18 PM

Similar Messages

  • How to change read only folders into normal ones...i can't get any filed from my harddrive

    how to change read only folders into normal ones...i can't get any filed from my hard drive..it shows read only

    Which HDD are you referring to, an external one, or the internal SSD?
    If external, which format is it in?

  • How to convert an int variable into String type

    hi everybody
    i want to know how to convert an interger variable into string variable
    i have to implement a code which goes like this
    Chioce ch;
    for(int i=0;i<32;i++)
    // here i need a code to convert the int variable i into a string variable
    ch.add(String variable);
    how do i convert that int variable i into a String type variable??
    can anyone help me?

    Different methods:
    int a;
    string s=a+"";or
    String.valueOf(int) is the better option because Int.toString() generated an intermediate object to get the endresult
    Ema

  • How to change the long in to string

    Hi
    In my program i get the long value as input.
    Then i send this long value to one method for testing which accepts the argument as String.So i have to change my long in to string then i pass it to the method.
    can anybody tell me how to change my long in to string?
    Thank you so much

    There's probably a method java.lang.Long.toString.
    If not, there's probably something a lot like it in either the Long or String classes.
    I'll leave you the pleasure of looking it up in the API docs.

  • How to change the Color of a string using swings/awt concept.

    Hi friends,
    How can i change the Color of a string.
    For ex:
    If i have a string "Welcome to the Java World",I want one particular Color for the string "Welcome to the" and a different Color to the "Java World" string.
    So please kindly help me out to resolve this issue.
    Thanking u in advance.

    "Text Component Features"
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

  • How to change the case structure to string input?

    Hi,
    I have the inner case structure that it will decide to set "DC Voltage" or "DC Current" mode. The "Output Function" contained the selection of function "DC Voltage" or "DC Current". So far it only work with DC Voltage not DC Current. My question is how do I change the case structure to string selector? When the output function is selected to DC Voltage then the case structure is selected DC voltage case. Please help Thanks.
    Attachments:
    test.vi ‏35 KB

    You don't really need to convert the value to a string? The problem is that the value of the individual ring items are not 0 and 1, as you assumed. The values generated by the controls are:
    DC Voltage: 1006
    DC Current: 1007.
    You can find this out by viewing the properties for the "Output Function" and going to the "Edit Items" tab.
    So, all you need to do is change the 0 to 1006 and the 1 to 1007 for your case items.
    By the way, your sequence frame serves no purpose.

  • E4X : How to get elements that contain a string pattern in the node name?

    Is there a way to extract children from an XMLList where the node name of a child contains a string pattern?
    For example :
    <record>
         <XblahX/>
         <cow/>
         <YblahY/>
    </record>
    How to get the elements of record that have a node name that contains the string "blah"?

    var rec:XML = <record>
         <XblahX/>
         <cow/>
         <YblahY/>
    </record>;
    var r:RegExp = /blah/;
    var elems:XMLList = rec.children().(localName().search(r)>-1);
    trace(elems.toXMLString())

  • How do I add an arrayList into a JList?

    Hey
    Wondering how you add an ArrayList's data into a JList? If anyone can show me something like:
                JList delList = new JList(/*insert arrayList here*/);Thanks!

    Wondering how you add an ArrayList's data into a
    JList? I've not tried but the API's suggest that:
    JList delList = new
    JList(myArrayList.toArray());
    /code]
    should work.
    http://java.sun.com/javase/6/docs/api/javax/swing/JLis
    t.html#JList(java.lang.Object[])
    http://java.sun.com/javase/6/docs/api/java/util/ArrayL
    ist.html#toArray()That will work just fine.
    @OP: Keep in mind that if your ArrayList contains objects which do not have an overridden toString() method, you may not get your desired results.

  • How to change the value of subtitution string in a page at runtime

    Hi,
    I need to change the value of a substitution string which is mentioned in application attributes at runtime.
    The value will be fetched from a field in database on load of each screen.
    Can anybody help.......
    Help will be appriciated........thanx in advance
    Sunil

    Substitution strings are meant to be static, like global constants.
    If you need some variable stuff, use application level items and set them using Application level computations/processes

  • How to change element in many pages and export to pdf?

    Hi guys!
    I've got a lot of Pages files with some text and graphic in the footer.
    I'd like to change this footer in all of them instantly and then export modified files to pdfs.
    Is that possible?

    I've tried but chosen not the best way..
    That's how I do it:
    1. Opening few Pages files (with editable footer)
    2. Copying every single pages to one Pages file.
    3. Editing footer in all of them instantly.
    4. But I'm exporting edited pages as one big PDF... And I want to export them seperately of course.
    Any idea how to do it fast and easy? Working with 100 files is real pain.
    Thanks for any help!

  • How to change internal number range into external number range

    Hi All,
    There is a number range in the system which was assigned internally by mistake earlier. Now, I want to change the internally assigned number range to external number range.
    Can anyone please let me know, the procedure to change used number range from internal number range to external number range and from external number range to internal number range.
    Quick reply will be appreciated & points will be assigned.
    Thanks & Regards,

    hi Mehak,
    you can try to simply change the range from ext to int (and vica versa). If that does not wrok, than you can delete the range and recreate it with proper settings. But you have to take into account that if you have a range as external from 1 to 10 and for example numbers 2 and 5 are taken already than you recreate the range 1..10 as internal, than you could have some problems. Probably best is in this case to recreate with other interval.
    hope this helps
    ec

  • How to change transparent PDF background into white background?

    Hi all, I have some text documents in PDF format and would like to edit it in photoshop CS5, but each time I open them up in photoshop, the background seems to be transparent (tiny grey and white tiles), which is very eye tiring when editing/annotating with a wacom pen, how to fill the background total white? Thanks.

    Ah, easy one. Create a new layer{Layer>New Layer}, then fill it with a color{Edit>Fill}Change content of the fill box to a color of your choosing.
    If you have windows the short cut for filling with foreground is alt-backspace and filling with background is ctrl-backspace. Short cut for fill dialog box is shift-backspace or shift-F5.
    A faster way to create a new layer is to use the icon just to the right of the trashcan at the bottom of the layers panel.
    A bit over winded in directions, but once you learn the shortcuts, it will be a snap to do.

  • HT2204 How to change my old ID into a new ID on my apps, ITunes and games?

    Hello there,
    I just change my Apple ID recently because I can't used my first time Apple ID, and now I have a new Apple ID with new password too. But the problem is that I can't change from my old ID and using the new ID. Every time I try to update the games or any apps that I purposes its coming with my old ID even though I have the new ID. And everything went wrong and I want change it using my new ID on all my Apps.
    Please could you tell me what o do with this and I think someone had Hacked my email or my Apple ID.
    Thank you.

    Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID.
    Apple ID FAQ
    http://support.apple.com/kb/HE37
    Also see Here   http://support.apple.com/kb/HE37
    I have multiple Apple IDs. Is there a way for me to merge them into a single Apple ID?
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.

  • How to change Transport request into local object $temp.?

    Hi experts,
    I would like to know to how to change a Transport request into and local object.
    I have already assigned Infopackage to TR, but its not required. We dont want this infopackage to be transported to prod. So how can i change that as a local object.
    Please put our valuable inputs.
    Thanks in advance.
    Regards,
    Dubbu

    Go To that Infopackage ,
    Extras Menu----Object catalog entry.  There you can change package name.
    or
    In SE09---Under the transport requests you can search for the infopackage name and delete from the TR.
    Regards,
    Srikanth
    Edited by: srikanth on Feb 19, 2009 2:26 PM
    Edited by: srikanth on Feb 19, 2009 2:27 PM

  • Can we get Arraylist from String.Please check the code

    Hi all,
    I have just pasted my code over here.Can anyone of you find the solution for obtaining the Array list from the String.
    For Example :
    ArrayList al = new ArrayList();
    al.add(new byte[2]);
    al.add("2");
    String stringVar = "" + (ArrayList) al;
    Here I can convert the arraylist into string.But can we do he vice versa like obtaining the above arraylist from the string?If please advice me.
    URGENT!!!!

    cudIf you run the code you posted you will observe that the string form of the list does not contain all the information of the list: in particular the array elements are missing. It follows that the "vice versa" conversion you seek is simply not possible.
    A variation on this theme is the following:import java.util.ArrayList;
    public class ListEg {
        public static void main(String[] args) {
            ArrayList al = new ArrayList();
            al.add("foo");
            al.add("bar, baz");
            String stringVar = "" + (ArrayList) al;     
            System.out.println(stringVar);
    }If you think about the output you should be able to conclude that lists with different contents can easily have the same string form.
    Just something to chew on.

Maybe you are looking for

  • Computer and TV monitors

    I am going to be getting a new MacPro and a HDMI card. For my computer monitors, I am currently using 2 - Acer AL2216W. I was wondering if anyone could suggest computer monitors (apple or not) that would be good to use while editing HD footage. Also

  • What's codec is needed?

    Hi there, folks I am preparing a music video for a film and have a week to do so. The film was cut on FCP HD uncompressed. At home the files show up fine, but on my laptop they play black. I am far from my home computer now, though. What is the codec

  • Web Forms and Security

    I am trying to automate the web form create filter task (in Hyperion planning). As I understand it there is no command line tool like Essbase does with Import.cmd command to load security filters. It is to taxing on the system to go to create a filte

  • Repair permissions differences

    Hi, What are the differences of repair permissions from Applications/utility/disk utility and from system DVD? only special permission? i think is better do it from system because is more upgrade. what do you think about?

  • Press button with CL_SALV_FUNCTIONS_LIST

    I made press button on an ALV available with: gr_func_list->set_all(    value  = IF_SALV_C_BOOL_SAP=>TRUE I want to delete just one these buttons (LOTUS). How can I do this with CL_SALV_FUNCITONS_LIST?