Ask Question
5 March, 15:31

Assign the size of userInput to stringSize. Ex: if userInput is "Hello", output is: Size of userInput: 5

+3
Answers (1)
  1. 5 March, 16:59
    0
    import java. util. Scanner;

    public class StringSize {

    public static void main (String [] args) {

    Scanner scnr = new Scanner (System. in);

    String userInput;

    int stringSize;

    userInput = scnr. nextLine ();

    / * Your solution goes here * /

    stringSize = userInput. length ();

    System. out. println ("Size of userInput: " + stringSize);

    return;

    }

    }

    Explanation:

    stringSize = userInput. length (); / / userInput. length () will get the length of the string and put in stringSize
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assign the size of userInput to stringSize. Ex: if userInput is "Hello", output is: Size of userInput: 5 ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers