Skip to content
Advertisement

Accessing array attributes from other classes with setter/getter

I’m new to Java and was wondering how to access attributes from other classes with setter/getter if they are arrays.

Currently, I have one date class that sets a date with parameters for month/day/year. I need to make another class that uses the date class to set a date of hire to store as an attribute, alongside others.

My code currently looks like this:

JavaScript

This is the second class:

JavaScript

The error says: Cannot invoke setDate(int[]) on the array type int[]

How can I fix this? Thanks!

Advertisement

Answer

You will need to create a DateClass object to use its methods. Consider changing your EmployeeClass like so:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement