Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help with Beginner JAVA method!

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Help with Beginner JAVA method!

    Hi guys I can't seem to get this method working. Any help is appreciated on what's wrong in my code thanks!

        /**
    public static final String SENTENCE_SEPARATORS = "[.?!]";
     
         * Given an ArrayList of lines from a text file, create a new array list
         * in which each entry is a sentence from the file 
         * with SENTENCE_SEPARATORS removed but no other changes.
         * A sentence is defined to be a sequence of characters that 
         * (1) is terminated by (but doesn't include) the characters ! ? . or the end of the file, 
         * (2) excludes whitespace on either end, and 
         * (3) is not empty.
         */
        public static ArrayList<String> convertFileLinesToSentences(ArrayList<String> filelines)
        {
            String allLines = "";
            for(String lines : filelines) { // add all lines into a single string
                allLines = (lines + " ");
            }
            String[] sentencesArray = allLines.split(SENTENCE_SEPARATORS);  // split at sentence separators
            ArrayList<String> entries = new ArrayList<>(Arrays.asList(sentencesArray)); // add sentences from array into ArrayList
            for(String sentence : entries) { // remove the sentence separators
                sentence.trim().replaceAll(SENTENCE_SEPARATORS, "");
            }
            return entries;
        }


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: Help with Beginner JAVA method!

    Neither do we. Can you provide more details such as copy and paste the exact error message (if you get one) or describe the behaviour and what it should do instead.
    Improving the world one idiot at a time!

Similar Threads

  1. Replies: 2
    Last Post: January 18th, 2013, 10:12 AM
  2. Replies: 1
    Last Post: January 6th, 2013, 05:32 AM
  3. [SOLVED] How to create a Java generic method, similar to a C++ template method?
    By Sharmeen in forum Object Oriented Programming
    Replies: 3
    Last Post: October 18th, 2012, 02:33 AM
  4. Help with beginner mutator method
    By Dysun in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 8th, 2012, 05:32 PM
  5. Beginner method call problem
    By Lasda in forum Java Theory & Questions
    Replies: 2
    Last Post: May 10th, 2011, 03:31 PM