I am using Java to get a
String input from the user. I am trying to make the first letter of this input capitalized.
I tried this:
String name;BufferedReader br = new InputStreamReader(System.in);String s1 = name.charAt(0).toUppercase());System.out.println(s1 + name.substring(1));
which led to these compiler errors:
Type mismatch: cannot convert from InputStreamReader to BufferedReader
Cannot invoke toUppercase() on the primitive type char
How do I make the first letter of a string uppercase, but not change the case of any of the other letters?
"this is a test"->
"This is a test"
"the Eiffel Tower"->
"The Eiffel Tower"
I'm sure that someone has solved this problem. I have a job title column in a table. I want to properly capitalize the job titles.
For example: computer and information research scientistShould be: Computer and Information Research Scientist
Thanks in advance,Bruce
I have a String description that holds my sentence. I only want to capitalize the first letter. I tried different things but most of them give me exceptions and errors. Im using Xcode 6.
Here is what I tried so far
let cap = [description.substringToIndex(advance(0,1))] as String description = cap.uppercaseString + description.substringFromIndex(1)
It gives me: Type 'String.Index' does not conform to protocol 'IntegerLiteralConvertible'
func capitalizedStringWithLocale(locale:0) -> String
But I just can't figure out how to make it work. Any ideas?
I'm looking for an example of how to capitalize the first letter of a string being entered into a text field. Normally, this is done on the entire field with a function, regex,
OnChange, etc. I want to capitalize the first letter while the user is still typing.
For instance, if I'm typing the word "cat", the user should press 'c', and then by the time he presses 'a', the C should be capitalized in the field.
I think what I'm going for might be possible with
keypress but I'm not sure where to start.
Anyone have an example for me?