#Cannot find the other java class containing methods

13 messages · Page 1 of 1 (latest)

solemn sentinel
#

Hi! I'm executing the code from Eclipse(thus saying that there is no problem and can find the other class), executing the code from the terminal gives me "cannot find symbol" error saying that it cannot find the other class called "Metodi".
Here's the codes:

package provaJava;

public class Programma {

    public static void main(String[] args) {
        
        
        String espressione = args[0];
        String valori = args[1];
        if(!(Metodi.checkEspr(espressione))) {
            System.out.println("Espressione non corretta!");
            System.exit(1);
        }
    }

}
package provaJava;

public class Metodi {
    
    static char[] valoriCorretti = new char[] {'A','B','C','D','E'};
    
    public static boolean checkEspr(String stringa) {
        
        boolean flag1 = false;
        boolean flag2 = false;
        boolean flag3 = false;
        
        if(stringa.length() < 5) {
            return false;
        }
        if(stringa.charAt(1) == '+' || stringa.charAt(3) == '-') {
            for(int i = 0; i < valoriCorretti.length; i++) {
                if(stringa.charAt(0) == valoriCorretti[i] || stringa.charAt(0) < 9) {
                    flag1 = true;
                }
                if(stringa.charAt(1) == valoriCorretti[i] || stringa.charAt(1) < 9) {
                    flag2 = true;
                }
                if(stringa.charAt(3) == valoriCorretti[i] || stringa.charAt(3) < 9) {
                    flag3 = true;
                }
            }
        }
        return (flag1 && flag2 && flag3);
    }
    
    
}

And there is a dump of the error:

upbeat kestrelBOT
#

This post has been reserved for your question.

Hey @solemn sentinel! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

bold fog
solemn sentinel
#

Does it need a main to function? saw from a post on stackoverflow that the user isn't using a main method... is it the static modifier that is causing the problem?

bold fog
#

Are the two pieces of code in the same file?

solemn sentinel
#

Nope, they are in two separate files. Same package and same directory.

bold fog
#

Try to put a main method in the second file

solemn sentinel
#

Nope, still doesn't work

bold fog
#

hmm, then u don’t know sorry

solemn sentinel
#

Np, I'll wait

polar geyser
solemn sentinel