So I'm quite new to Java and this is the first time I'm working with objects. Could you help me out with why this piece of code doesn't work?
public class Object
{
String a1;
String[] a2;
int a3;
double a4;
long a5;
}
And here is the main class:
public class Main
{
public static void main(String[] args)
{
Object obj1 = new Object("example text", new String[] {"some", "more", "examples", "here"}, 1, 1.0);
}
}
Error message:
java: constructor Object in class Object cannot be applied to given types; required: no arguments found: java.lang.String,java.lang.String[],int,double reason: actual and formal argument lists differ in length
Objectis a built-in type. Call your class something else. And if you want to pass arguments tonew, write a constructor in it.