Task
A string of characters of a certain length is specified. Determine the new term, obtained after lengthening the initial one for each character met once and turning over. Example: a = ”abac” rez = “ccabba”.
I did everything except the last point. It is necessary that duplicate characters in a line be derived once, without doubling. I don’t know how to do it
import java.util.Scanner; public class MainFive { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Введите строку:"); String str = sc.nextLine(); int ln = str.length(); char[] chars= str.toCharArray(); for (int i=ln-1; i>=0; i--){ System.out.print(chars[i]+""+chars[i]); } } }