It seems to me that calling string.length() each time takes significantly longer than just accessing a variable.
It seems to me that calling string.length() each time takes significantly longer than just
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Stringimplements interface CharSequence, which in turn defineslengthmethod. You couldn’t do the same with variables since variables can’t be abstract or overridden.As other people say, Java is using interfaces heavily.