013-001-008

Getting String Length

Easy

Problem Description

Getting String Length

In this problem, you will create a program that calls the length() method on a String variable to obtain the number of characters and displays the result to standard output.

Learning Objective: Understand how to get the length of a string using the length() method of the String class

Overview

When working with strings in Java, knowing their length (number of characters) is a fundamental operation. The String class provides the length() method to get the length of a string.

Specifications

  1. Declare a String variable message and initialize it with "Hello, Java!"
  2. Use the length() method to get the length of the string
  3. Output the result in the specified format

Output Format

Length: 12

Test Cases

※ Output examples follow programming industry standards

Input:
Expected Output:
Length: 12
Input:
Expected Output:
Length: 12
Input:
Expected Output:
Length: 12
Input:
Expected Output:
Length: 12
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 7 free executions remaining