0

I am just wondering how am I suppose extract the numerical value for the string. I have a constructor that is :

public Calender(String month, String day, String year) {
}

I know I have to use the split() and Integer.parseInt(), but I am not sure how to use it.

Any help?

Thanks

1
  • 1
    Look in the Related section. Commented Apr 11, 2014 at 4:02

2 Answers 2

1

how to use it: look here

public Calender(String month, String day, String year) {

    int mon=Integer.parseInt(month);//converts month(String) to (mon)Integer 
     int dy=Integer.parseInt(day);//converts day(String) to (dy)Integer
     int yr=Integer.parseInt(year);//converts year(String) to (yr)Integer


}
Sign up to request clarification or add additional context in comments.

2 Comments

You need to assign these values to fields, not to local variables.
As poster asked, so for his/her understanding i did it locally, the poster can declare variable to globally if he/she wants means. even poster didnt post more information at all.
1

Try Integer.parseInt(YOUR_STRING_HERE).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.