Make it a class variable in the class where the array is. Its initial value of 0 will be where the first element is to go in the array then increment for the next element. Its value at any time will...
Type: Posts; User: Norm
Make it a class variable in the class where the array is. Its initial value of 0 will be where the first element is to go in the array then increment for the next element. Its value at any time will...
If at any time you call the objectadd method to add an element to the array, where will it put that one element? How will it keep track of where the next empty element is located?
Why the loop in objectadd()? It should add one object. The caller of object will call it for as many times as it wants to add a new Module to the student.
In display you should use the length of the...
What happens when you execute it?
Look at the second part of post #25
Which part don't you understand?
1)add a method? see the display method. its a method that you pass a Module object to
2)add objects to the array. See the Student class's constructor. It adds...
You haven't followed my suggestions (which I see were not clear). You should NOT put your testing code into the Student class's constructor.
Have main pass the size of the array to the Student...
You should get rid of all static variables.
Only the value of the last data assigned is present in all the instances because they are sharing one static variable instead of having their own...
Please explain what the problem is and show what you want the output to look like.
The output reminds me of problems using static variables.
Only the value of the last data assigned is present in...
That would define a variable: modules known only in the main method. The class variable with the same name would still not have a value.
If you want to assign a value to the modules variable leave...
Yes that assigns a value to one of the slots in an existing array, but you need to define it first.
What if modules[] had 2 slots, would you be able to assign values to the 10th slot?
Before you...
Where do you assign a value to the "this.modules" variable? You define it but never give it a value.
In your printout, What variable is null? Your print out does not have an id String with the null line.
You read the stack trace from the bottom up.
At line 54 in main() the code calls the...
Which variable is null on line 21? Why is it null? Did you assign any value to that variable?
Please explain. Do you mean it prints spaces or blanks?
Change your println statement to have a...
On line 21 You need to print out the value of this.modules and modules.
On line 33 you need to print out the value of Module and modules.
The error has moved to line 33. What variable on line 33 is null?
You never posted line 21 so I can't help you determine which variable on that line is null.
What variable is null?
Post the contents of line 21 if you need help finding the variables that are used on that line.
look at line 21 in the Student class. There is a variable there with a null value. Backtrack in your code to find out why and fix the code so that the variable has valid value.
If you can not see...