Java tutorial
//package com.java2s; public class Main { public static String toUpperString(String s) { int idx = 0; for (; idx < s.length(); idx++) { char c = s.charAt(idx); if (c >= 'a' && c <= 'z') { break; } } if (idx == s.length()) { return s; } StringBuilder buf = new StringBuilder(s.substring(0, idx)); for (; idx < s.length(); idx++) { buf.append(toUpper(s.charAt(idx))); } return buf.toString(); } public static char toUpper(char c) { if (c >= 'a' && c <= 'z') { c -= 0x20; } return c; } }