Java - Write code to Convert string to Upper Case using StringBuffer


Write code to convert string to Upper Case


//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "";
    }//from  w  w  w .ja  v a2 s  . co m

    public static String toUpperCase(String str) {
        StringBuffer buffer = new StringBuffer(str);
        for (int i = 0; i < buffer.length(); i++) {
            char c = buffer.charAt(i);
            buffer.setCharAt(i, Character.toUpperCase(c));
        return buffer.toString();

Related Exercise