Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to change elements in ArrayList into String

807601May 2 2008 — edited May 2 2008
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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2008
Added on May 2 2008
2 comments
379 views