String s= sc.nextLine(); //Suppose I take HH:MM (Time) as string... say 09:45
So s becomes...
s = "09:45";
My question is how do I take HH = 09 and MM = 45 as numbers in integer variable in JAVA.
I have tried ...
String s1[]= s.split(":");
int HH= Integer.valueof(s1[0]);
int MM= Integer.valueof(s1[1]);
But it is giving this exception...
Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at appstreet.Question1.main(Question1.java:42)