need help with creating a method using arrays


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: need help with creating a method using arrays

  1. #1
    Join Date
    Feb 2003
    Posts
    11

    need help with creating a method using arrays

    Hello,

    I am currently in the process of creating a program using a TextField to input String values. I want to input
    10 numbers in an array. Here is is my question. How do i
    call the method getData() below?

    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(); //??? }


    // method for getData() (not sure if this is correct)

    public void getData(){
    for (int i=0; i< stringArray.length; i++)
    stringArray [i] = (input.getText());}

  2. #2
    Join Date
    Mar 2003
    Posts
    84
    need to pass a referance of the array.


    so your getData method is going to be called


    public void getData(String[] stringArray)





    and when you call it, you'll need to pass the array.

    getData(stringArray)


    you follow that? or need more detail.
    I'm surprised more of you people don't get hit by cars.

  3. #3
    Join Date
    Feb 2003
    Posts
    11

    thanks for your reply but there is a problem

    The statement

    public void getData(String [] stringArray);
    ^


    is producting an error that says 'class' or 'interface' expected. Im thinking it has a problem with the word void , but im not sure.


    thanks for your reply..

    ______________________
    Jbowl to the nineth degree

  4. #4
    Join Date
    Mar 2003
    Posts
    84
    remove the ;
    I'm surprised more of you people don't get hit by cars.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center