JAVA: How to take a string and return the capitalized format of a word

katrinaatomic

New Member
\[code\]int length = s.length();if (length = 0){ return s;}else { return s.charAt(0).toUpperCase()+ s.substring(1);}\[/code\]I get two errors saying:\[code\]if (length = 0){^^^^^^^^^^Type mismatch: cannot convert from int to booleanreturn s.charAt(0).toUpperCase()+ s.substring(1); ^^^^^^^^^^^^^^^^^^^^^^^^^Cannot invoke toUpperCase() on the primitive type char\[/code\]Plus, if it's an empty sting it should just return it.That's why I'm using an If-Else statement.Help please!
 
Top