Waj
Waj

Reputation: 301

Error: “; Expected Not a statement ”

For the line data[] = {nam, addres, adminStaf, phoneNumbe, typ}; NetBeans gives me this error

"; Expected Not a statement" 

I don't know why this is not working, help will be appreciated.

public Object[] getObjects() {

           Object[] data = {};

            for (int i = 0; i < Storage.getAgencies().size(); i++)
            {
                String nam = Storage.getAgencies().get(i).getName();
                String addres = Storage.getAgencies().get(i).getAddress();
                String adminStaf = Storage.getAgencies().get(i).getAdminstaff();
                String phoneNumbe = Storage.getAgencies().get(i).getPhonenumber();
                String typ = Storage.getAgencies().get(i).getType();

                data[] = {nam, addres, adminStaf, phoneNumbe, typ};
            }
            return data;
        }

Upvotes: 0

Views: 1642

Answers (1)

Maroun
Maroun

Reputation: 95978

The syntax you're using is only allowed when initializing an array. You should do the following instead:

data = new String[] {nam, addres, adminStaf, phoneNumbe, typ};

Upvotes: 3

Related Questions