StringBuilder to Upper Case - Java java.lang

Java examples for java.lang:StringBuilder

Description

StringBuilder to Upper Case

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        StringBuilder builder = new StringBuilder();
        toUpperCase(builder);// ww  w  . j  a v  a  2  s . c  o m
    }

    public static void toUpperCase(StringBuilder builder) {
        for (int i = 0; i < builder.length(); i++) {
            if (Character.isLowerCase(builder.charAt(i))) {
                builder.setCharAt(i,
                        Character.toUpperCase(builder.charAt(i)));
            }
        }
    }
}

Related Tutorials