Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * (c) Winterwell Associates Ltd, used under MIT License. This file is background IP.
 */

import java.lang.reflect.Method;

public class Main {
    public static boolean hasMethod(Object obj, String method) {
        assert method != null;
        Method[] ms = obj.getClass().getMethods();
        for (Method m : ms) {
            if (m.getName().equals(method))
                return true;
        }
        return false;
    }

    /**
     * Lenient equals: null = ""
     * @param a
     * @param b
     * @return true if a=b
     */
    public static boolean equals(String a, String b) {
        if (a == null || a.length() == 0)
            return b == null || b.length() == 0;
        return a.equals(b);
    }
}