Write code to uppercase All characters in a string
//package com.book2s; public class Main { public static void main(String[] argv) { String s = "book2s.com"; System.out.println(upcaseAll(s)); }/*from w ww . j a v a 2 s . co m*/ public static String upcaseAll(String s) { if (s == null || s.equals("")) { return ""; } StringBuffer sb = new StringBuffer(); char[] c = s.toCharArray(); for (int i = 0; i < c.length; i++) { if (c[i] >= 97) { sb.append((c[i] + "").toUpperCase()); } else { sb.append(c[i]); } } return sb.toString(); } }