0

I was wondering if anyone would be able to show me how to convert an arraylist to normal array in Jsp?

1 Answer 1

1
yourArrayList.toArray()

but this won't be generic.. to use the generic version, let's assume you've got an ArrayList<Yourclass>. Just do:

YourClass[] array = yourArrayList.toArray(new YourClass[0]);

A side note: JSP is not a language but a container of Java code and html so what you need is Java code..

Sign up to request clarification or add additional context in comments.

1 Comment

Here you created an empty array (new YourClass[0]) which is soon discarded. This would be much better: yourArrayList.toArray(new YourClass[yourArrayList.size()]); The same array will be returned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.