hi guys im trying to capitalise the first letter of every string however it doesn't seem to work.
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
BufferedReader in = new BufferedReader(reader);
String line = in.readLine();
while ((line = in.readLine()) != null) {
String output = line.substring(0, 1).toUpperCase() + line.substring(1) + " ";
System.out.println(output);
}
}
}
the system inputs a sentence like "stack overflow" and needs the output to be "Stack Overflow" so every letter is capital.
It seems to only put the same input, no change. i have searched everywhere online however most resources are only for the first string.
any help would be appreciated.