The charAt method returns a character and you're trying to assign it to a String variable. Fixing that should prevent the second error.
You can turn a character into a string by adding a blank string with it.
String s = ""+value.charAt(0);
Your output still won't look right since you're outputting carA and restA.
carA equals whatever the user inputted, its not changed anywhere. So the first part written to the screen will be the entire input string capitalized.
restA equals carA, the same thing minus the first character. When you pass only 1 argument when calling substring, it returns the rest of the string from that character position and on to the end.
For example:
String carA = "something";
restA = carA.substring(1);
restA will equal "omething".
You're using 'value' to grab the first character but never actually doing anything with it.
Here's an example:
String input = "this is a test";
String fixed = input.substring(0,1).toUpperCase() + input.substring(1).toLowerCase() + ".";
System.out.println(fixed);
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Offline 856 posts
since Mar 2004