0

can someone please help me to solve this? Thank you

String a = 1||2||3
String b = 2||4||5

String c = 1||2||3||4||5|| //Must be uniqe
2

1 Answer 1

1

Using converting to arrays or lists? I do not know what your mean. but I suggest

String a = "1||2||3";
String b = "2||4||5";
String[] arrayA = a.split("||");
String[] arrayB = b.split("||");
List<String> list = Arrays.asList(arrayA);
list.addAll(Arrays.asList(arrayB));            
System.console().printf(list.stream().distinct().collect(Collectors.joining("||")));
Sign up to request clarification or add additional context in comments.

Comments

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.