Java Variables


I have a code but I am struggling with one concept.
When prompted the user inputs a four letter word which is processed into the code but it requires the word to be broken up into its consisting letters.
Input = "Dogs"
What line(s?) of code do I need to break it into

var a = "D"
var b = "o"
var c = "g"
var d = "s"

As well as a four word limiter, so they can only input four letters.


What if you need to process a book? Creating a variable for each character isn't very manageable. Let the computer do the repeating instead, this is what loops are for.

Also, var is a javascript keyword, it doesn't exist in java

Strings already provide easy access to its characters, there might not even be any need to put them in another data structure.

For limiting the length you can look at the length of the string and ask again or ignore the rest


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.