Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a few methods defined in 1 .java file, while the main is in another file, one of these methods is this one:

public void saveParking (String fileName)throws FileNotFoundException { //ESTATICO?
   File fichero = new File(fileName);
   int numMaxZone = 0;
   int temp = 0;
   int temp_int = 0;
   int numero = 0;

   if (fichero.exists() == true) {
       PrintWriter pw = new PrintWriter(fichero);
       temp = (int)maxZone;
       temp_int = 64;
       numMaxZone = temp - temp_int;
       numero = sizeZone + 1;
       pw.println(numMaxZone + numero); //ESCRIBO EN EL FICHERO LAS DIMENSIONES
       for (int i=0; i<numMaxZone; i++) {
       for (int j=0; j<numero; j++) {
           pw.println(carSpaces[i][j].toText());
       }
       }
   }else{
       PrintWriter pw2 = new PrintWriter(fichero);
       temp = (int)maxZone;
       temp_int = 64;
       numMaxZone = temp - temp_int;
       numero = sizeZone + 1;
       pw2.println(numMaxZone + numero); //ESCRIBO EN EL FICHERO LAS DIMENSIONES
       for (int i=0; i<numMaxZone; i++) {
       for (int j=0; j<numero; j++) {
           pw2.println(carSpaces[i][j].toText());
       }
       }

   }
   }


which I then invoke from the main

new P3b().saveParking(args[2]);


Which gives me the "cannot find symbol" error

What I have tried:

I have another method, which is a constructor set as public, and this one doesn't give me this error when I invoke it in the main

I've also checked that each parenthesis before the start of the next method matches with the first parenthesis after the method signature
Posted
Updated 18-Mar-22 2:33am

1 solution

Okay, right after posting this, I just realized that maybe creating an object of P3b while looking for a method of another class may not be the best idea. So i just changed the method calling lines to: new Parking().methodName()
 
Share this answer
 
Comments
Greg Utas 18-Mar-22 8:37am    
When you have more information about your original question, please just edit your question and add it there. This isn't a Solution and, even if it was, it's considered inappropriate to post a Solution to your own Question.
Richard MacCutchan 18-Mar-22 10:22am    
You need to ensure that the Parking class is named:
public class Parking
{
}

and contains the methods you are trying to call. You also need to ensure that the generated Parking.class file is in the same directory as your main class, or can be found through the java,class.path environment variable, or the -classpath option on the java invocation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900