English

Differentiate between charAt() and substring(). - Computer Applications

Advertisements
Advertisements

Question

Differentiate between charAt() and substring().

Distinguish Between

Solution

S. No. charAt() substring()
1. Returns a character in the String at the nth place, counting from the 0th position. This function extracts a set of characters from a specified index up to the end of a string.
2.

Example:

a = "computer";
System.out.println(a.char At(5)); 

Example:

Strings = "ThanksBspAcp";
System.out.println(s.substring(6));
3. In the above example, t is printed. In the above example, BspAcp is printed.
shaalaa.com
  Is there an error in this question or solution?
Chapter 4: String Handling - EXERCISES [Page 289]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 4 String Handling
EXERCISES | Q VI. 4. | Page 289
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×