Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDalton Coble
6,489 PointsI keep getting two errors over one thing. please help
Code:
import java.util.Date;
import com.teamtreehouse.Treet;
public class Example {
public static void main(String[] args) {
Treet treet = new Treet(
"craigsdennis",
"Want to be famous? Simply tweet about Java and use the hashtag #treet. I’ll use your tweet in a new @treehouse course about data structures.",
new Date(1421849707000L)
);
System.out.printf("This is a new Treet: %s \n", treet);
System.out.println("The words are: ");
for (String word: treet.getWords()) {
System.out.println("word");
}
}
}
package com.teamtreehouse;
import java.util.Date;
public class Treet {
private String mAuthor;
private String mDescription;
private Date mCreationDate;
public Treet(String author, String description, Date creationDate) {
mAuthor = author;
mDescription = description;
mCreationDate = creationDate;
}
public String toString() {
return "Treet: \"" + mDescription + "\" - @" + mAuthor;
}
public String getAuthor() {
return mAuthor;
}
public String getDescription() {
return mDescription;
}
public Date getCreationDate() {
return mCreationDate;
}
}
public String[] getWords() {
return mDescription.toLowerCase().split("[^\\w#@']+")
}
1 Answer
Sam Wilskey
3,420 PointsHello Jody Shackelford,
I took a look at the code and found a couple of errors that might help you out. It is tough to tell if some of the errors came from copy and pasting because the formatting is hard to follow but hopefully this will help!
First it looks like you are accidently closing the class at
public Date getCreationDate() { return mCreationDate; } }
The second closing bracket needs to be the last thing in that file/class.
Second inside of the function:
public String[] getWords() { return mDescription.toLowerCase().split("[^\w#@']+") }
You are just missing a second \ before the w. The split statement should be:
public String[] getWords() { return mDescription.toLowerCase().split("[^\\w#@']+") }
Hope this helps!
Mari Johannessen
12,232 PointsMari Johannessen
12,232 PointsHi Jody! What are the errors you keep getting?