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

  • SEARCH
  • Home
  • 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 8753315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:24:06+00:00 2026-06-13T13:24:06+00:00

I have problem with declaration of variable. iam trying to prepare code using Multi

  • 0

I have problem with declaration of variable. iam trying to prepare code using Multi threading
but i have problem with declaration of variable. Now iam confused, whether is possible to put Scanner into second not main class- i suppose that yes, but i don´t know how declare variable. Exception is – Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – non-static variable this cannot be referenced from a static context
at test1.PIN.main …

public class PIN{

    static int a;

class Runner extends Thread{

public void run(){

    Scanner sc = new Scanner(System.in);
    for(int i= 1; i<4; i++){
    System.out.println("PUT your PIN: ");
    int a = sc.nextInt();

                try {
                    Thread.sleep(100);
                } catch (InterruptedException ex) {
                    Logger.getLogger(PIN.class.getName()).log(Level.SEVERE, null, ex);
                }

 if(a ==1234){
     System.out.println("PIN  OK");
 } else {System.out.println("PIN NOK");}   

}
}
}

public static void main(String[] args){

    Runner r = new Runner();
    r.start();
  • 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-13T13:24:07+00:00Added an answer on June 13, 2026 at 1:24 pm

    Declare Runner static inner class. Non static inner classes are instance bound so you need outer class instance to create object of non-static inner class. And because your inner class is not static you can not access it inside main which is static-context

    static class Runner extends Thread
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code so far, but the problem is that after the user
I have problem with my query on C, I’m using the oci8 driver. This
I have problem SIMILAR to preventing form data reposting, but not quite the same
I have a problem trying to solve a situation, when I use Java Reflection
I have a seemingly basic problem with C# arrays. I am a beginner, but
Hi I have a small problem in my ANTLR tree grammar. I am using
I have this table variable declaration followed by a query: DECLARE @CurrentItems TABLE (
I have a problem with the #define in C I am using MSP430F5418 with
I am trying to do my assignment but I am having a problem instantiating
I am trying to do an assignment for class, but I have run into

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.