سؤال

i'm new to this forum, first of all i would like to say thanks for reviewing my question.

I'm receiving this message: The method CreandoFunciones() is undefined for the type CreandoFunciones. I'm new @ Java, i try a few things, but nothing.

Any help would be appreciated. Thanks

package funciones;
import java.util.Scanner;

public class Funciones1 {

private static Scanner scan;

public static void main(String[] args) 
{
    CreandoFunciones link = new CreandoFunciones();
    {

        int menu;
        scan = new Scanner(System.in);
        System.out.println("Opción: ");
        menu = scan.nextInt();

        switch(menu)
        {
        case 1: 
            link.CreandoFunciones();
            break;
        case 2:
               System.out.println("C'est la vie!");
               break;
        case 3:
                System.out.println("Alors on danse!");
                break;
        default: System.out.println("Owned.");      
        }

}
  }
}


package funciones;

public class CreandoFunciones {

public CreandoFunciones()
{
        System.out.println("Testing");
}

}
هل كانت مفيدة؟

المحلول

CreandoFunciones() is a constructor of the class not a usual method. So you cannot call like link.CreandoFunciones();. to perform operation in link 1 create a separate method in the class.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top