snake_case to camelCase
Mediumjava
Convert a snake_case identifier to camelCase: remove each underscore and capitalise the letter that followed it.
Input: one token in snake_case (lowercase letters, digits and single underscores between parts; no leading or trailing underscore).
Output: one line — the camelCase form.
Example 1
Input
total_student_marks
Output
totalStudentMarks
- 1 <= length <= 60
Hint 1
Walk the characters. On '_', set a flag to upper-case the next letter.
Hint 2
Otherwise append the character (upper-cased if the flag is set), then clear the flag.
Hint 3
Use a StringBuilder for the result.
Scan left to right. An underscore is dropped and tells you the next character should be upper-cased; every other character is copied as-is. A name with no underscores comes out unchanged.