Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2011
    Location
    Manchester, UK
    Posts
    2
    Rep Power
    0

    Default problem with array

    hi,

    I have a task to do at uni. Its a map drawn in applet and basically I have a TextField called "A comment"and when I put something like "restaurant: good food" the program should check if the input contains string ""restaurant" and if it does the comment "good food" goes into an array where all comments are stored.

    my code is:
    Java Code:
    String comment;
    String [] commentList=new String[1000];
    int count=0;
    
    if (comment.contains("church:")) {
    
    count++;
    
    commentList[count-1]=comment;
    
    
    ...
    It is just a little bit of my code to give you a picture of what im trying to do.

    I am really stuck here and I need a help plase!

    Regards Adrian

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: problem with array

    I'm not really sure what your question is. Where exactly are you stuck? If you want help, you should put together an SSCCE that demonstrates exactly what you have so far.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: problem with array

    Java Code:
    count++;
     
    commentList[count-1]=comment;
    Different way of doing it. Why increment first?
    Java Code:
    commentList[count]=comment;
    count++;

Similar Threads

  1. Replies: 0
    Last Post: 05-12-2011, 07:04 PM
  2. array problem
    By aizen92 in forum New To Java
    Replies: 26
    Last Post: 12-21-2010, 05:42 AM
  3. array problem
    By jabo in forum New To Java
    Replies: 2
    Last Post: 03-31-2010, 09:54 AM
  4. Array problem
    By c3jcarmy in forum New To Java
    Replies: 11
    Last Post: 03-11-2010, 02:45 AM
  5. array problem
    By Albert in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 01:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •