English

Write a statement in Java to extract the last four characters from the word "SIMPLICITY". - Computer Science (Theory)

Advertisements
Advertisements

Question

Write a statement in Java to extract the last four characters from the word "SIMPLICITY".

Very Short Answer
Advertisements

Solution

System.out.println("SIMPLICITY".substring(6)); 

Explanation:

The substring() function extracts a segment of a string from start to end index-1. "SIMPLICITY".substring(6) extracts characters from index 6 to the end.

shaalaa.com
  Is there an error in this question or solution?
2021-2022 (March) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×