Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * return either the first space or the first nbsp
     */
    public static int findSpace(String haystack, int begin) {
        int space = haystack.indexOf(' ', begin);
        int nbsp = haystack.indexOf('\u00A0', begin);
        if (space == -1 && nbsp == -1) {
            return -1;
        } else if (space >= 0 && nbsp >= 0) {
            return Math.min(space, nbsp);
        } else {
            // eg one is -1, and the other is >= 0
            return Math.max(space, nbsp);
        }
    }
}