This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd)); 1) Bic 2) ic 3) icy 4) error: no method matching substring(int,char) The answer is (4). Does the char value always get converted to int, even in the case of substring function?
Hi geeta, the answer is 2 and not 4 as you pointed out. The 'char' datatype is implicitly casted to 'int' since 16-bit fits perfectly in 32-bit. The signatures for the substring method are: 1) substring (int beginIndex) 2) substring (int beginIndex, int endIndex) Hope this helps.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!