aspose file tools*
The moose likes Beginning Java and the fly likes need help with array program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need help with array program" Watch "need help with array program" New topic
Author

need help with array program

Jbowl
Greenhorn

Joined: Mar 11, 2003
Posts: 5
hello,
im trying to create a program that uses a method
getData to read 10 strings in an array from a TextField. Im getting an error on the method getData that says 'class' or 'interface' expected. Can anyone help me on this issue? thanks --jbowl
private TextField input;
private String [] stringArray = new String [10];

public void init()
{ input = new TextField (20);
add (input);
input.addActionListener (this);}
public void paint(Graphics g)
{getData(stringArray);
g.drawString(toString(), 50,50);}

public void actionPerformed (ActionEvent e)
{ input.setText(null);
repaint ();}
}

// This section below contains the method getData
public void getData (String [] array)
{for (int i=0; i< array.length; i++)
array [i] = (input.getText());}



_ _____________________ _ <br />Jbowl to the nineth degree
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Is this code all contained in a class?

It looks like you may have an extra closing brace "}" just after the actionPerformed method.
[ March 28, 2003: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
BTW, welcome to Java Ranch. Would you please check out our JavaRanch Naming Policy and change your displayed name accordingly.
Thanks -Barry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help with array program
 
Similar Threads
string array question
need help with string array using methods
need help with string array
need help with string array using methods
need help sorting a string array alphabetically