Java Java Data Structures Organizing Data Splitting Strings

shambhu kumar
shambhu kumar
1,433 Points

return mBody.toLowerCase().split("[\\s+]"); why i get expected 11 return 12 as error

why i get expected 11 return 12 as error

com/example/BlogPost.java
package com.example;

import java.util.Date;

public class BlogPost {
  private String mAuthor;
  private String mTitle;
  private String mBody;
  private String mCategory;
  private Date mCreationDate;

  public BlogPost(String author, String title, String body, String category, Date creationDate) {
    mAuthor = author;
    mTitle = title;
    mBody = body;
    mCategory = category;
    mCreationDate = creationDate;
  }
public String[] getWords(){
return mBody.toLowerCase().split("[\\s+]");
}
  public String getAuthor() {
    return mAuthor;
  }

  public String getTitle() {
    return mTitle;
  }

  public String getBody() {
    return mBody;
  }

  public String getCategory() {
    return mCategory;
  }

  public Date getCreationDate() {
    return mCreationDate;
  }
}

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

The plus goes on the outside of the character search, otherwise you are splitting on any space character and plus signs.

Hope that helps!