013-001-007

String Class Basic Methods

Easy

Problem Description

String class Basic Methods

In this problem, you will create a program that calls key String class methods (length(), charAt(), toUpperCase()) on the string "hello" 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 uses String class methods to get the length, retrieve a character at a specific position, and convert to uppercase for a given string.

Specifications

  1. Store the string "hello" in a variable text
  2. Use length() to get the character count and print in the format "Length: 5"
  3. Use charAt(0) to get the first character and print in the format "First: h"
  4. Use toUpperCase() to convert to uppercase and print in the format "Upper: HELLO"

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