Tutorial
For such basics in Java, study The Java™ Tutorials by Oracle.com, free of charge.
Wrong class syntax
You need curly-braces to define a class. You used parentheses.
Also, the word class is required.
package work.basil.example.classes;
import java.time.LocalDate;
public class Customer
{
String firstname;
String secondname;
LocalDate birthdate;
String mail;
String phonenmbr;
String adress;
String postnumber;
String postplace;
}
Or colocate in a single line some field members of the same type.
public class Customer
{
String firstname, secondname, mail, phonenmbr, adress, postnumber, postplace;
LocalDate birthdate;
}
Mark the member fields final if you intend for them to be shallowly-immutable. You will then need to define a constructor as well to populate the values.
public class Customer
{
final String firstname, secondname, mail, phonenmbr, adress, postnumber, postplace;
final LocalDate birthdate;
public Customer ( final String firstname , final String secondname , final String mail , final String phonenmbr , final String adress , final String postnumber , final String postplace , final LocalDate birthdate )
{
this.firstname = firstname;
this.secondname = secondname;
this.mail = mail;
this.phonenmbr = phonenmbr;
this.adress = adress;
this.postnumber = postnumber;
this.postplace = postplace;
this.birthdate = birthdate;
}
}
Records
If the main purpose of your class is to transparently communicate shallowly-immutable data, define your class as a record.
For defining a record, we do use parentheses to define the member fields, similar to the code in the Question. A record also has a pair of curly-braces, left empty if you want default behaviors.
In a record, the compiler implicitly creates the constructor, getters, equals & hashCode, and toString.
public record Customer
( String firstname ,
String secondname ,
String mail ,
String phonenmbr ,
String adress ,
String postnumber ,
String postplace ,
LocalDate birthdate )
{ }
Example usage
In modern Java, there is no need to repeat the generics type of the ArrayList. Use empty <> on the right side.
Also, generally best to use the highest-level of abstraction (super-class or super-interface) that meets your needs. So instead of referring to your list as an ArrayList, refer to it as a List, SequencedCollection, or Collection.
No need to include the word list in your variable’s name. You may well decide in the future to change to a different concrete class that is not a List, such as a SequencedSet like TreeSet. The plural customers will suffice.
SequencedCollection < Customer > customers = new ArrayList < > ( );
customers.add
(
new Customer
( "AARON" ,
"SMITH" ,
"[email protected]" ,
"92081" ,
"Testveien 109A" ,
"1234" ,
"OSLO" ,
LocalDate.of ( 1980 , 1 , 1 )
)
);
Where an unmodifiable list is appropriate, use List.of for convenient literals-style syntax.
SequencedCollection < Customer > customers =
List.of
(
new Customer
( "AARON" ,
"SMITH" ,
"[email protected]" ,
"92081" ,
"Testveien 109A" ,
"1234" ,
"OSLO" ,
LocalDate.of ( 1980 , 1 , 1 )
)
);
Dump to console
You can print description of your objects, with text generated by the toString method.
Commonly used is either this:
System.out.println ( "customers = " + customers );
… or this:
customers.forEach ( System.out :: println );
Octal numbers
You wrote:
LocalDate.of(1980,01,01),
Do not add a leading zero to your int literals. The leading zero means an octal (base-8) literal, not a decimal (base-10) literal.
LocalDate.of( 1980 , 1 , 1 )
IDEs
Most Java programmers write their code within an IDE such as IntelliJ, Eclipse, or NetBeans. For students, BlueJ. These tools will help you in drafting your class, and will point out deficiencies.