Java String Tokens

  • + 4 comments

    here is the code but it showing errors in 4 casee out of 11 why.

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        scan.close();
    
        // Split the string into tokens
        String[] tokens = s.split("[ !,?._'@]+");
    
        // Print the number of tokens
        System.out.println(tokens.length);
    
        // Print each token on a new line
        for (String token : tokens) {
            System.out.println(token);
        }
    }
    

    }