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!
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 trial
Matthew Earlywine
2,560 PointsError with my workspace
The error I keep getting is: ./com/teamtreehouse/Treet.java:57: error: cannot find symbol
return getWordsWithPrefixedWith("#");
^
symbol: method getWordsWithPrefixedWith(String)
location: class Treet
./com/teamtreehouse/Treet.java:61: error: cannot find symbol
return getWordsWithPrefixedWith("@");
^
symbol: method getWordsWithPrefixedWith(String)
location: class Treet
package com.teamtreehouse;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
public class Treet implements Comparable<Treet>, Serializable {
private static final long serialVersionUID = 7146681148113043748L;
private String mAuthor;
private String mDescription;
private Date mCreationDate;
public Treet(String author, String description, Date creationDate) {
mAuthor = author;
mDescription = description;
mCreationDate = creationDate;
}
@Override
public String toString() {
return String.format("Treet: \"%s\" by %s on %s",
mDescription, mAuthor, mCreationDate);
}
@Override
public int compareTo(Treet other) {
if (equals(other)) {
return 0;
}
int dateCmp = mCreationDate.compareTo(other.mCreationDate);
if (dateCmp == 0) {
return mDescription.compareTo(other.mDescription);
}
return dateCmp;
}
public String getAuthor() {
return mAuthor;
}
public String getDescription() {
return mDescription;
}
public Date getCreationDate() {
return mCreationDate;
}
public List<String> getWords() {
String[] words = mDescription.toLowerCase().split("[^\\w#@']+");
return Arrays.asList(words);
}
public List<String> getHashTags() {
return getWordsWithPrefixedWith("#");
}
public List<String> getMentions() {
return getWordsWithPrefixedWith("@");
}
private List<String> getWordsPrefixedWith(String prefix) {
List<String> results = new ArrayList<String>();
for (String word : getWords()) {
if (word.startsWith(prefix)) {
results.add(word);
}
}
return results;
}
}
1 Answer

Paul Ryan
4,584 Pointsreturn getWordsWithPrefixedWith("#");
Should that not be getWordsPrefixedWith?
Just a simple typo, with a little bit of a cryptic error.

Matthew Earlywine
2,560 PointsGeez!!! Thanks, I did need some fresh eyes cause I wasn't seeing anything wrong.

Paul Ryan
4,584 PointsCould you mark this answer as correct so others won't visit this question. Thanks
Cena Mayo
55,236 PointsCena Mayo
55,236 PointsHey Matthew, just noting that I added syntax highlighting to your code and changed the topic from JavaScript to Java. :)