013-001-007
String Class Basic Methods
Easy
Problem Description
String class Basic Methods
In this problem, you will create a program that reads a string from standard input, calls key String class methods (length(), charAt(), toUpperCase()), and displays the character count, first character, and uppercase conversion to standard output.
Learning Objective: Understand the basics of text processing using key methods of the String class (length(), charAt(), toUpperCase()) from Java's standard library
Overview
Write a program that reads a string from standard input and uses String class methods to get the length, retrieve a character at a specific position, and convert to uppercase.
Input Format
A string (e.g. hello)
Specifications
- Read a string from standard input and store it in a variable
text - Use
length()to get the character count and print in the format"Length: X" - Use
charAt(0)to get the first character and print in the format"First: x" - Use
toUpperCase()to convert to uppercase and print in the format"Upper: XXX"
Output Format
Length: 5
First: h
Upper: HELLO
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