Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int getStrLength(String content) {
        int length = 0;
        int tempLength = 0;
        for (int i = 0; i < content.length(); i++) {
            String temp = content.charAt(i) + "";
            if (temp.getBytes().length == 3) {
                length++;
            } else {
                tempLength++;
            }
        }
        length += tempLength / 2 + ((tempLength % 2) == 0 ? 0 : 1);
        return length;
    }
}