PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, June 26, 2022

[FIXED] What does "a cannot be resolved" mean in Java?

 June 26, 2022     compiler-errors, java     No comments   

Issue

I'm trying to program an appointment program and I'm a beginner at java. I'm using VScode.

the code:

public class Main {
    public static void main(String[] args) throws FileNotFoundException, IOException {                  
        a.menuPrint(); //Prints menu to begin 
    }
}

I'm getting this error:

a cannot be resolved

 at Main.main(Main.java:7) 

The a variable is supposed to print the menu. I don't know why it can't be resolved. Are there any reasons why?


Solution

There is not enough information here to decide. Typically "cannot be resolved" means that you are using an object that is not declared in the block where it is being used and it is not global.

In your example, variable a is being used in the main method. If a is not a global variable, that explains the problem: inside the method body, a is not defined (cannot be resolved to whatever type that variable is).

To fix:

public static void main(String[] args){
    WhateverClass a = new WhateverClass();
    a.menuPrint();
}


Answered By - hfontanez
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing