Users Pricing

forum

Home Forums Take out year from input – MindStick

Take out year from input

Anonymous User 1891 20 Dec 2015
public class NewClass {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Input your place and date birth : ");
        String birth = in.nextLine();
    }
}
And I will input MindStick, 25 Dec 2015. The problem how to change my input from string to int, and how to take only the year. So I can use for
if (2015 - year < 20 ) {
    System.out.println ("You are teen");
}

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md