• Post Reply Bookmark Topic Watch Topic
  • New Topic

[ASK] Array of String as parameter method  RSS feed

 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello master,

I create array of String as parameter in method like this :



But i try to access in other method in same class in return NULL,



Please help me.
Thanks before
 
Campbell Ritchie
Marshal
Posts: 56527
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot see what is going wrong in that code. Please tell us what printouts you get from that setData method.
Your getNilai method is incorrectly named, because a getXXX method should return the field (or a copy of it).
 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I cannot see what is going wrong in that code. Please tell us what printouts you get from that setData method.
Your getNilai method is incorrectly named, because a getXXX method should return the field (or a copy of it).


Thank you for your response.

If print out in the method :

I get null value.

If i print out in the current method :

I get the value that i wanted.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fandy Akhmad wrote:If print out in the method [getNilai()]
I get null value.
If i print out in the current method: [setData(String[] data)]
I get the value that i wanted.

OK, so why do you think that is?

Hint: What are you doing differently?

Winston

PS: Please don't use bolding unless you really need to. See our KeepItDown (←click) page for details.
 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Fandy Akhmad wrote:If print out in the method [getNilai()]
I get null value.
If i print out in the current method: [setData(String[] data)]
I get the value that i wanted.

OK, so why do you think that is?

Hint: What are you doing differently?

Winston

PS: Please don't use bolding unless you really need to. See our KeepItDown (←click) page for details.


Oh i am sorry for that, i just use for make detail.

I already, make any change :
- make array and getter and setter. in setter i passing that value. But it just return null value.

and in code above is my last step. I am stuck in there.
I just want to pass data from another JInternalFrame to another JInternalFrame. Usually try to pass from JFrame to another JFrame, its OK because it have main method that directly executed.

Thank you.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fandy Akhmad wrote:I just want to pass data from another JInternalFrame to another JInternalFrame. Usually try to pass from JFrame to another JFrame, its OK because it have main method that directly executed.

Don't start worrying about fancy things like JInternalFrame's until you've got your current code working. You'll only distract yourself from the real problem.

I'll say again: What are you doing differently between those two pieces of code? When you answer that, you'll have have the reason why you're getting nulls.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!