Answer the question
In order to leave comments, you need to log in
Is it possible to simplify this code in Java (working with a string)?
Good afternoon. As an input to the automated test, I submit data arrays (String), which can be in English, Russian or null. I get a very long string like:
String JobPlace = ((start.JobPlace.length > 1 ? start.JobPlace[cc] : start.JobPlace[0]) == null) ? null : new String(((start.JobPlace.length > 1) ? start.JobPlace[cc] : start.JobPlace[0]).getBytes(), StandardCharsets.UTF_8);
Answer the question
In order to leave comments, you need to log in
String JobPlace = start.JobPlace.length > 1 ? start.JobPlace[cc] : start.JobPlace[0];
if (JobPlace != null)
JobPlace = new String(JobPlace.getBytes(), StandardCharsets.UTF_8);
Personally, it is not convenient for me to read this, this form of recording does not give a performance gain, but it reads worse.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question