This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Array mistaken for a function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array mistaken for a function" Watch "Array mistaken for a function" New topic
Author

Array mistaken for a function

Bill Raterink
Greenhorn

Joined: Sep 03, 2003
Posts: 29
Hi, I'm posting this here because I'm obviously a beginner. If it belongs elsewhere, please let me know. TIA Now, I have a program that is comming along nicely, kudos to you folks here... but the following code causes me some problems. Com1 is a text field, & I want to set it to th i-th element of an array (Comment1), but I get a compiler error that Comment1(int) is not found in my class. Of course it's not, but what am I doing wrong. The second line works flawlessly.
Com1.setText(Comment1(Idx));
Com1.setText("Anything");
I've been thru several books & tutorials & I just don't seem to see HOW to set/get data into/out of a textField.

Thanks again, -Bill.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
It should be
Com1.setText(Comment1[Idx]);
Use [] and not ()


Mani
Quaerendo Invenietis
Bill Raterink
Greenhorn

Joined: Sep 03, 2003
Posts: 29
Thank you so much for the help. I only regret not asking 6 hrs ago.
Thanks, -Bill.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Array mistaken for a function
 
Similar Threads
Access the COM1 port
How Access COM1 port in Java
Possible error in K&B book (resolved - no error)
Low level Programing
How should file output be done?