Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe to all free courses

How to declare or make a Java method, class and fields as Deprecated ?.

Program to demonstrate how to declare or make a Java method, class and fields as Deprecated.





Click here to download complete source code 


@Deprecated
public class Calculator {
 
 @Deprecated
 public int sum(int x , int y){
  return x + y;
 }
 
 public int sum(int ... numbers) {
  int sum = 0;
  for(int number : numbers) {
   sum = sum + number;
  }
  return sum;
 }
 
 public static void main(String [] args) { 
  Calculator calculator = new Calculator();
  int result = calculator.sum(5, 10);
  System.out.println("The sum is : " + result);
  
  result = calculator.sum(5, 5, 10, 15);
  System.out.println("The sum is : " + result);
  
 }
 
}



Click here to download complete source code
 
© 2021 Learn Java by Examples Template by Hubberspot