Peniel Uthayakumar
Peniel Uthayakumar

Reputation: 33

Why am i getting a message 'Obsolete Methods on the Stack' in Java on Eclipse while compiling code,

I'm running java on Eclipse 2020-06 Windows7 64bit,

When I run my programm which is to get input from the user and print some message depending on the number they input, I get a dialogue box opening up saying 'Obsolete Methods on the Stack',

 'Obsolete Methods on the Stack'

Here is the programm I wrote, Can someone please help me,

import java.util.Scanner;

public class ForcesBackup {
    
    public void ForcesBackup() {
        
        try (Scanner scan = new Scanner (System.in)) {      
            
            int criminals = scan.nextInt();
             
            if (criminals <= 5) {
                System.out.println("I got it");
            }
            else if (criminals > 5 && criminals <= 10  ) {
                System.out.println("Get me some backup");
            }
            else if (criminals > 100 && criminals <= 100 ) {
                System.out.println("Bring in heavy forces !!! ");
            }
             else 
             System.out.println("Good luck out there");
        }
             
    }

    public static void main(String[] args) {
        
        ForcesBackup police = new ForcesBackup();
        police.ForcesBackup();
    }
        
}

Upvotes: 1

Views: 1134

Answers (1)

When you make changes to a class while your program is running, Eclipse will try to swap in the new code in your running program without requiring a restart. However, this message is telling you that some of the code you changed was in the process of actually executing, and it can't swap it in, so you'll have to restart the application to see your changes.

Upvotes: 3

Related Questions