Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Arrays not compile

  1. #1
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Arrays not compile

    Hi:
    Whats wrong here:
     
    public class EmpleadoApp {
     
        public static void main(String[] args) {
     
            //Creamos un array de objetos de la clase empleados
            Empleado arrayObjetos[]=new Empleado[3];
     
            //Creamos objetos en cada posicion
            arrayObjetos[0]=new Empleado("Fernando", "Ureña", 23, 1000);
            arrayObjetos[1]=new Empleado("Epi", "Dermis", 30, 1500);
            arrayObjetos[2]=new Empleado("Blas", "Femia", 25, 1200);
     
            //Recorremos el array para calcular la suma de salarios
     
            int suma=0;
            for (int i=0;i<arrayObjetos.length;i++){
                suma+=arrayObjetos[i].getSalario();
            }
            System.out.println("La suma de salarios es "+suma);
        }
     
    }

    Compilation error:
    ----jGRASP exec: javac -g EmpleadoApp.java
    EmpleadoApp.java:6: error: cannot find symbol
    Empleado arrayObjetos[]=new Empleado[3];
    ^
    symbol: class Empleado
    location: class EmpleadoApp
    EmpleadoApp.java:6: error: cannot find symbol
    Empleado arrayObjetos[]=new Empleado[3];
    ^
    symbol: class Empleado
    location: class EmpleadoApp
    EmpleadoApp.java:9: error: cannot find symbol
    arrayObjetos[0]=new Empleado("Fernando", "Ureħa", 23, 1000);
    ^
    symbol: class Empleado
    location: class EmpleadoApp
    EmpleadoApp.java:10: error: cannot find symbol
    arrayObjetos[1]=new Empleado("Epi", "Dermis", 30, 1500);
    ^
    symbol: class Empleado
    location: class EmpleadoApp
    EmpleadoApp.java:11: error: cannot find symbol
    arrayObjetos[2]=new Empleado("Blas", "Femia", 25, 1200);
    ^
    symbol: class Empleado
    location: class EmpleadoApp
    5 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,318
    Thanks
    53
    Thanked 2,392 Times in 2,346 Posts

    Default Re: Arrays not compile

    EmpleadoApp.java:6: error: cannot find symbol
    Empleado arrayObjetos[]=new Empleado[3];
    ^
    symbol: class Empleado
    location: class EmpleadoApp
    The compiler can not find a definition for the class Empleado. Make sure the definition for class Empleado is on the classpath.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Arrays not compile

    Now have this error:

    ----jGRASP exec: javac -g Empleado.java
    Empleado.java:9: error: constructor Empleado in class Empleado cannot be applied to given types;
    arrayObjetos[0]=new Empleado("Fernando", "Ureħa", 23, 1000);
    ^
    required: no arguments
    found: String,String,int,int
    reason: actual and formal argument lists differ in length
    Empleado.java:10: error: constructor Empleado in class Empleado cannot be applied to given types;
    arrayObjetos[1]=new Empleado("Epi", "Dermis", 30, 1500);
    ^
    required: no arguments
    found: String,String,int,int
    reason: actual and formal argument lists differ in length
    Empleado.java:11: error: constructor Empleado in class Empleado cannot be applied to given types;
    arrayObjetos[2]=new Empleado("Blas", "Femia", 25, 1200);
    ^
    required: no arguments
    found: String,String,int,int
    reason: actual and formal argument lists differ in length
    Empleado.java:17: error: cannot find symbol
    suma+=arrayObjetos[i].getSalario();
    ^
    symbol: method getSalario()
    location: class Empleado
    4 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,318
    Thanks
    53
    Thanked 2,392 Times in 2,346 Posts

    Default Re: Arrays not compile

    Empleado.java:9: error: constructor Empleado in class Empleado cannot be applied to given types;
    arrayObjetos[0]=new Empleado("Fernando", "Ureħa", 23, 1000);
    ^
    required: no arguments
    found: String,String,int,int
    reason: actual and formal argument lists differ in length
    The compile can not find a constructor that takes these arguments: String,String,int,int
    The compiler did find a constructor that takes no arguments.

    Check the definition for the Empleado class's constructor to see what arguments it takes.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Arrays not compile

    Great Thanks!

Similar Threads

  1. Replies: 6
    Last Post: September 24th, 2014, 11:04 AM
  2. Failed to compile, URGENT please help. Can't compile using JDK
    By sauyang in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 18th, 2013, 07:16 AM
  3. Cannot get to compile
    By theoneyouenvy in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 19th, 2011, 10:17 PM
  4. [SOLVED] I CANT COMPILE
    By savvas in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 31st, 2011, 11:34 AM
  5. *why won't this compile?*
    By dcshoecousa in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 2nd, 2010, 07:18 PM