Use the @Deprecated annotation to mark the deprecated method.
Use the @Deprecated Javadoc tag to mark the method as deprecated within the documentation.
import java.math.BigInteger; public class Main { public static void main(String[] args) { BigInteger[] arr = new BigInteger[2]; arr[0] = new BigInteger("1"); arr[1] = new BigInteger("25"); // Use the older, deprecated method System.out.println(addNumbers(1, 25)); // Use the newer, non-deprecated method System.out.println(addNumbers(arr)); }/*from ww w . j a v a 2s .co m*/ /** * Accepts two values and returns their sum. * * @param x * @param y * @return * @deprecated The newer, more robust addNumbers(BigInteger[]) should now be * used */ @Deprecated public static int addNumbers(int x, int y) { return x + y; } /** * Newer, better method that accepts an unlimited number of values and returns * the sum. * * @param nums * @return */ public static BigInteger addNumbers(BigInteger[] nums) { BigInteger result = new BigInteger("0"); for (BigInteger num : nums) { result = result.add(num); } return result; } }