fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone {
  9. static String inputString = "field=value\nfield2=value2\nfield3=value3";
  10. public static String changeCase( String s ) {
  11. boolean capitalize = true;
  12. char[] output = new char[s.length()];
  13. for( int i = 0; i < s.length(); i++ ) {
  14. char input = s.charAt(i);
  15. if ( input == '\n' ) {
  16. capitalize = true;
  17. output[i] = input;
  18. } else if ( input == '=' ) {
  19. capitalize = false;
  20. output[i] = input;
  21. } else {
  22. output[i] = capitalize ? Character.toUpperCase(input) : input;
  23. }
  24. }
  25. return new String(output);
  26. }
  27.  
  28. public static void main (String[] args) throws java.lang.Exception {
  29. System.out.println( changeCase(inputString) );
  30. }
  31. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
FIELD=value
FIELD2=value2
FIELD3=value3