Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9079019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:45:10+00:00 2026-06-16T19:45:10+00:00

I have recently started reading into annotations. I deprecated the armStrong() method here and

  • 0

I have recently started reading into annotations. I deprecated the armStrong() method here and I need to suppress the deprecation warning but wherever I put it it says “unnecessary @SuppressWarnings(“deprecation”)”.

Can anyone tell me where to place it so that the method is deprecated warning would not come anymore?

import java.io.*;
import java.lang.annotation.*;
import java.lang.reflect.Method;

@Retention(RetentionPolicy.RUNTIME)

@interface number
{
String arm();
}

public class Ch10LU2Ex4
{  
@Deprecated
@number(arm = "Armstrong number")
public static void armStrong(int n)
 {
    int temp, x, sum = 0;
    temp = n;
    while(temp!=0)
     {
        x = temp%10;
        sum = sum+x*x*x;
        temp = temp/10;
     }
    if(sum==n)
     {
        System.out.println("It is an armstrong number");
     }
    else
    {
        System.out.println("It is not an armstrong number");
    }
 }

public static void main(String[] args) 
  {

    try
    {   
        Ch10LU2Ex4 obj = new Ch10LU2Ex4();
        obj.invokeDeprecatedMethod();
        Method method = obj.getClass().getMethod("armStrong", Integer.TYPE);
        Annotation[] annos = method.getAnnotations();
        for(int i = 0; i<annos.length; i++)
        {
            System.out.println(annos[i]);
        }
    }
    catch(Exception e)
     {
        e.printStackTrace();
     }
  } 
    @SuppressWarnings("deprecation")
    public void invokeDeprecatedMethod()
    {
        try
        {
        System.out.println("Enter a number between 100 and 999:");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        Ch10LU2Ex4.armStrong(x);
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
    }
  }  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:45:11+00:00Added an answer on June 16, 2026 at 7:45 pm

    This is a feature, not a bug. You don’t need a @SuppressWarnings for a call to a deprecated method of a class from within that class itself, because such calls don’t generate a deprecation warning in the first place. Calls to the deprecated method from other classes will need the @SuppressWarnings annotation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never used multiple inheritance but while reading about it recently I started
I have recently started reading about dependency injection and it has made me rethink
I have recently started reading about data mappers and all the articles I've found
I have recently started learning C++, but I require a compiler. I have tried
I have recently started reading up on Grails and would like to use SQL
I have recently started learning java as my first ever step into object oriented
I have recently gained interest in Google Chrome Extensions, so I started looking into
I have recently started reading Programming Challenges book by S. Skiena and believe or
I have recently started reading about Java EE6 and in the examples I follow
I have recently started messing round with CodeIgniter and ran into problems when doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.