L
L
lolchik2020-10-16 15:28:04
Java
lolchik, 2020-10-16 15:28:04

How to make text output line by line?

you need to write a function that will output each letter of the variable line by line.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Lee, 2020-10-16
@SashaDown

If you mean that from the word "word" you need to get: with
a word
, then I think this is possible:

public static String func(String str){
    String strchar = "";
    for(int i = 0; i < str.length(); i++)
        strchar = strchar.concat(str.charAt(i)+"\n");
    return strchar;
}

length - determines the length of the word
charAt() - extracts the character specified by index
concat - joins strings

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question