Results 1 to 8 of 8

Thread: Dynamic array

  1. #1
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Dynamic array

    Hi,

    I wrote a java program which takes a string and makes every word in a cell..
    Whatever the size of the string,a table should be created with a size=number of the string words

    How can i do that?

    thank you

  2. #2
    Mong is offline Member
    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0

    Default Re: Dynamic array

    You can use ArrayList, it is easy to use, similar to array, and have helpful methods.
    import java.util.ArrayList;

  3. #3
    Mong is offline Member
    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0

    Default Re: Dynamic array

    Also, ArrayList expands as you add each element, which is exactly what is needed here

  4. #4
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: Dynamic array

    the problem is that i need to use the method "asList" and it takes as a parameter 'a String array'

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: Dynamic array

    Why do you 'need' to use that method? If it's a pita, don't use it; also showing a bit of code, showing what you're talking about, might help.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: Dynamic array

    i need in my program to integrate the "treeTagger" (a free tool)
    there is a short program which analyses some words an gives me,for each word,if it is a verb or an adjectif or...this is the role of treetagger.
    Java Code:
    tt.process(asList(new String[] { "This", "2.1", "a", "test", "." }));
    this is the code which does that and as you see, "asList" is a method that needs a string array

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: Dynamic array

    That piece of code assumes that the class where that code is in also has an asList( ... ) method defined (or in a superclas thereof); is that true? Is that method giving any problems? What problems?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: Dynamic array

    This is my class and the method doesn't give me any problem :

    Java Code:
    import static java.util.Arrays.asList;
    
    public class Example {
            public static void main(String[] args) throws Exception {
    System.setProperty("treetagger.home", "/TreeTagger/models/TreeTagger");
                    TreeTaggerWrapper tt = new TreeTaggerWrapper<String>();
     try {
                            tt.setModel("/TreeTagger/models/TreeTagger/lib/french.par:iso8859-1");
                            tt.setHandler(new TokenHandler<String>() {
                                    public void token(String token, String pos, String lemma) {
                                            System.out.println(token + "\t" + pos + "\t" + lemma);
                                    }
                            });
    tt.process(asList(new String[] { "This", "2.1", "a", "test", "." }));
                    }
                    finally {
                            tt.destroy();
                    }
                   }
           
       }
    Last edited by manou2324; 04-28-2013 at 09:31 PM.

Similar Threads

  1. Return the current size of dynamic array
    By RozenKristal in forum New To Java
    Replies: 13
    Last Post: 10-01-2012, 08:04 PM
  2. Dynamic array.
    By kapil1089theking in forum New To Java
    Replies: 1
    Last Post: 11-04-2011, 05:51 PM
  3. Dynamic String Array?
    By ladykrimson in forum New To Java
    Replies: 4
    Last Post: 10-13-2010, 04:37 AM
  4. How increase dynamic array?
    By artemff in forum New To Java
    Replies: 5
    Last Post: 01-01-2010, 12:22 AM
  5. Dynamic GUI
    By ike2u in forum New To Java
    Replies: 4
    Last Post: 08-08-2009, 02:50 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
  •