0

Need solution

What is the output? String a="code"; System.out.println(a.substring(2)); How the output de?

14th Dec 2022, 6:54 AM
Mustakim Rahman
Mustakim Rahman - avatar
2 Answers
+ 6
String::substring method() has two overloads, as covered in the following links https://beginnersbook.com/2013/12/java-string-substring-method-example/ 1st overload accepts an index and returns a copy of the string, starting from the character at the given index, till end of string. 2nd overload accepts a range of index, and returns a copy of the string starting from character at first given index and ends with the character at the second given index.
14th Dec 2022, 7:54 AM
Ipang
+ 4
The substring of "code" , from index 2 to till end is "de".
14th Dec 2022, 7:47 AM
Jayakrishna 🇼🇳