SRL Archive - Java Help and Tutorials

Java Help - "The name is Null"??


Sax

2013-09-11 11:00:46

Hi. It's me again :(

I have this:

[ATTACH=CONFIG]22189[/ATTACH]

[ATTACH=CONFIG]22190[/ATTACH]

I get that error down in that box. Why is it returning null?



OFFTOPIC: How do I end the script in java, like here we do TerminateScript.


Thanks :D

euphemism

2013-09-11 12:00:00

In your banana constructor:


name = thisname;

your are assigning thisname's value to the parameter. Since thisname is never initialized the parameter's value is being set to null. That is beside the point, as what you have done is flipped around your assignment statement. Should be:


thisname = name;

Also, you can call the 'thisname' variable 'name' and do something like:


this.name = name;

To terminate a Java program you can use


System.exit(0);

Sax

2013-09-11 13:03:06

From: euphemism
In your banana constructor:


name = thisname;

your are assigning thisname's value to the parameter. Since thisname is never initialized the parameter's value is being set to null. That is beside the point, as what you have done is flipped around your assignment statement. Should be:


thisname = name;

Also, you can call the 'thisname' variable 'name' and do something like:


this.name = name;

To terminate a Java program you can use


System.exit(0);



Thank you :D