compare Long and return 1, 0, -1 - Java java.lang

Java examples for java.lang:long

Description

compare Long and return 1, 0, -1

Demo Code

/*******************************************************************************
 * Copyright (C) 2013, 2015 Swirly Cloud Limited. All rights reserved.
 *******************************************************************************/
//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        long lhs = 42;
        long rhs = 42;
        System.out.println(compareLong(lhs, rhs));
    }/* w  w w. j  a  v  a2  s . co m*/

    public static int compareLong(long lhs, long rhs) {
        int i;
        if (lhs < rhs) {
            i = -1;
        } else if (lhs > rhs) {
            i = 1;
        } else {
            i = 0;
        }
        return i;
    }
}

Related Tutorials