Размер видео: 1280 X 720853 X 480640 X 360
Показать панель управления
Автовоспроизведение
Автоповтор
For any doubts, live training updates, internship program and free Courses, please join our Telegram channel t.me/qafoxoriginal
By using Stream APIsScanner scanner = new Scanner(System.in); System.out.print("Enter string: "); String userInput = scanner.nextLine().trim().replace(" ", ""); Map characterAndCount = userInput.chars() .mapToObj(i -> (char) i) .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));//to print the characters and its count. characterAndCount.forEach((character, aLong) -> System.out.println(character + " : " + aLong));
For any doubts, live training updates, internship program and free Courses, please join our Telegram channel t.me/qafoxoriginal
By using Stream APIs
Scanner scanner = new Scanner(System.in);
System.out.print("Enter string: ");
String userInput = scanner.nextLine().trim().replace(" ", "");
Map characterAndCount = userInput.chars()
.mapToObj(i -> (char) i)
.collect(Collectors.groupingBy(Function.identity(),
Collectors.counting()));
//to print the characters and its count.
characterAndCount.forEach((character, aLong) -> System.out.println(character + " : " + aLong));