DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
barbaraips profile image
Bárbara Perdigão • Edited

I wanted to take my chances with these challenges, but I decided to start from the beginning, so here's my (super) late entry, done in Java :

public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("Type the word:");
        String word = scan.nextLine();

        if (word.length() > 2) {
            System.out.printf("Result: %s%n", word.substring(1, word.length() - 1));
        } else {
            System.out.println("Invalid word.");
        }

}
Enter fullscreen mode Exit fullscreen mode