πŸ–₯ Computer Science

What is the best way of concatenating strings found in an array of length n?

2 answers
Answered Oct 18Computer Science
Anna's profile picture
Anna ChaseKnowledgeable, Calm and Patient tutor 516 students helped

you should be using ArrayLists, and your output should be an ArrayList. Once you've made these your pre-condition, the operation is built-in--first.addAll(second). The only case where this wouldn't be pretty much automatic is when your arrays are non-object types (int, long, double, ...), in that case, intrinsic arrays can have a big advantage over ArrayLists--but for Strings

Answered Oct 18Computer Science
MW
Michael WigginsI am passionate about teaching, and have more than 10 years of experience

String ccyPair = ccy1 + ccy2; I\'m utilizing cyPair as a key in a HashMap and it\'s brought in a tight circle to recover esteems. When I profile then this is the bottleneck java.lang.StringBuilder.append(StringBuilder.java:119) java.lang.StringBuilder.(StringBuilder.java:93)

Ask questions

Tutors

Get an answer in 5 minutes from expert tutors at Oxford, Cambridge, Imperial and more.

Get an answer