πŸ–₯ Computer Science

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

2 answers
Anna ChaseKnowledgeable, Calm and Patient tutor 17.5k 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

Michael WigginsI am passionate about teaching, and have more than 10 years of experience17.5k students helped

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 a question

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

Get started