A
A
artshelom2017-04-13 17:26:41
Java
artshelom, 2017-04-13 17:26:41

How to improve java code??

At the interview, they asked me to improve the code, but I could not answer with advice on improvement ((
Tell me, how could I answer ??

Spring bes="";
for(int i=0;i<10;i++){
bes+="_";
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2017-04-13
@artshelom

Use the StringBuilder class, now with each operation you allocate memory for a new string and copy the data there. bes+="_";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question