Java- How to parse and input and store its values into 'int' variables -



Java- How to parse and input and store its values into 'int' variables -

sorry if obvious question, new java , not sure how it. tried looking online couldn't understand talking about. want take user input illustration date "2014 02 22 21 14". note spaces separate each variable stored.

i want parse , store 2014 int variable called year , store 02 int variable called month , 22 stored day int variable.

could please show me illustration of how great.

public class helloapp { public static void main(string[] args) { // show dateformat user, can come in format system.out.println("the date format is: yyyy mm dd"); scanner sc = new scanner(system.in); string datestring = sc.nextline(); string[] tokens = datestring.split(" "); int year = integer.parseint(tokens[0]); int month = integer.parseint(tokens[1]); int day = integer.parseint(tokens[2]); system.out.println("year :" +year); system.out.println("month :" +month); system.out.println("day :" +day); } }

java

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -