public class UpperCase { public static void main(String[] args) { String str = " this is a man"; String temp = upperCase(str); System.out.println(temp); } public static String upperCase(String str){ char[] c = str.toCharArray(); for (int i = 1; i < c.length; i++) { if(c[i-1]==' ') c[i]=(char) (c[i]-32); } String s = new String(c); return s; } }