Declare a character variable (char ch). Read a character into the variable ch and then store it in a String variable using the valueOf method. Print out both the char and string value at the end to test your program.
(Note that the valueOf method is static... this means that the method can be called without an instance of the class. Therefore you can say String.valueOf, this is similar to how you’ve used the random method in the math class.)

Recommended Answers

All 3 Replies

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"

and if you copy paste your assignment, make sure you have the correct one. there's no such thing as a "string value" (case sensitive and such)

that assignment tells you literally what to do, it almost types it out for you.
If you still can't do it, it means you've not paid any attention in class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.