Java Number Min Value minChar(String input)

Here you can find the source of minChar(String input)

Description

Get the minimum character within the String object.

License

Apache License

Parameter

Parameter Description
input - The input <code>String</code> object.

Return

int

Declaration

public static int minChar(String input) 

Method Source Code

//package com.java2s;
/**/*ww w.  j  a v a 2 s  . co  m*/
 * Copyright (C) 2015-2016 OurBeehive(http://ourbeehive.github.io/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * Project Name: MyBatisPioneer
 * File Name: StringHelper.java
 * Package Name: org.ourbeehive.mbp.util
 * 
 * Date: Jan 20, 2016
 * Author: Sericloud
 * 
 */

public class Main {
    /**
     * Get the minimum character within the <code>String</code> object.
     * 
     * @param input
     *            - The input <code>String</code> object.
     * @return int
     */
    public static int minChar(String input) {

        if (input == null) {
            throw new NullPointerException();
        }

        int min = 0;
        int len = input.length();
        int ch = 0;

        for (int i = 0; i < len; i++) {
            ch = input.charAt(i);
            if (ch < min) {
                min = ch;
            }
        }

        return min;
    }
}

Related

  1. min3(int x, int y, int z)
  2. min4(double v1, double v2, double v3, double v4)
  3. MIN4(int x, int y, int z, int a)
  4. min8(double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8)
  5. MIN_MAX(int min, int mid, int max)
  6. minCharsForCriteria(final int length, final int criteria)
  7. minCommonMultiple(int m, int n)
  8. minComparable(T first, T second)
  9. minCoverageEstimate(short mask)