Java examples for java.lang:int
compare Int and return 1, 0, -1
/******************************************************************************* * Copyright (C) 2013, 2015 Swirly Cloud Limited. All rights reserved. *******************************************************************************/ //package com.java2s; public class Main { public static void main(String[] argv) { int lhs = 42; int rhs = 42; System.out.println(compareInt(lhs, rhs)); }// w ww . j a v a2 s .co m public static int compareInt(int lhs, int rhs) { int i; if (lhs < rhs) { i = -1; } else if (lhs > rhs) { i = 1; } else { i = 0; } return i; } }