013-001-012

Basic String Class Operations

Medium

Problem Description

Basic String class Operations

In this problem, you will create a program that reads a string, substring range, and search word from standard input, then calls String class methods (length(), charAt(), substring(), indexOf(), toUpperCase(), toLowerCase()) and displays the results.

Learning Objective: Understand commonly used String class methods

Overview

Java String class has many methods for string manipulation. Apply basic methods like length(), charAt(), substring(), indexOf() to a string read via Scanner.

Input Format

string
substring start index
substring end index
search word

Specifications

  • Store the first line string in a variable
  • Use the second and third lines as start/end indices for substring()
  • Use the fourth line as the search word for indexOf()
  • Display length, first character, substring, search result, and uppercase/lowercase conversions

Output Format

Length: X
First char: Y
Substring(start,end): Z
Index of word: N
Upper: UPPER_STRING
Lower: lower_string

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up