M
M
Michael2015-01-04 23:19:33
Java
Michael, 2015-01-04 23:19:33

NullPointerExeption on initialization?

I'm new to programming (I'm learning about the possibilities of OOP), please explain what is the cause of this error. Since when designing, the IDE does not produce any syntax errors. The code is the following:

public static Male[] m;
public static Female[] f;

public static void main(String[] args) {

for(int i = 0; i<10; i++)
     m[i] = new Male("Adam",1333,23.00f);
        
for(int i = 0; i < m.length; i++)
     System.out.println(m[i].WhoAreYou());

What is the reason for such an error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uadeveloper, 2015-01-04
@cocain1988

The size of an array must be specified before it is used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question