Domanda di colloquio di Koch

How would you count characters in a string.

Risposta di colloquio

Anonimo

29 set 2022

public class CountCharsInString { public static void main(String[] args) { String exampleString = "This is just a sample string"; long totalCharacters = exampleString.chars().filter(ch -> ch != ' ').count(); System.out.println("There are total " + totalCharacters + " characters in exampleString"); } }