+ 1

Can someone please debug my program?

I am trying to make a program in Java, here is the code: public class Program { public String color; public int size; public int age; public void Program(String c, int s, int a){ this.color = c; this.size = s; this.age = a; System.out.println("Color: " + this.color + " Size: " + this.size + " Age: " + this.age); } public static void main(String[] args) { Program take = new Program("Blue", 13, 14); } } --------------------------------------------------------------------------------------------- But, whenever I try to run it, I always get this error: ..\Playground\:9: error: constructor Program in class Program cannot be applied to given types; Program take = new Program("Blue", 13, 14); ^ required: no arguments found: String,int,int reason: actual and formal argument lists differ in length 1 error ---------------------------------------------- PLEASE HELP! Thanks so Much!

10th Feb 2017, 2:10 AM
Sathvik Kuthuru
Sathvik Kuthuru - avatar
4 Respostas
+ 9
The constructor Program() cannot have a return type. Remove "void" and it should work. public Program(String c, int s, int a)
10th Feb 2017, 2:16 AM
Tamra
Tamra - avatar
+ 5
yw :D
10th Feb 2017, 2:42 AM
Tamra
Tamra - avatar
+ 1
Thank you so MUCH Tamra!
10th Feb 2017, 2:32 AM
Sathvik Kuthuru
Sathvik Kuthuru - avatar
0
Just use class name in constructer Program(String c, int s, int a). No need public.
10th Feb 2017, 5:13 AM
Sinan Ceylan
Sinan Ceylan - avatar