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 trial

Java Java Data Structures - Retired Exploring the Java Collection Framework Using ArrayLists

Jose Torres
PLUS
Jose Torres
Courses Plus Student 2,493 Points

Can someone help me to see where i went wrong. Console returns cannot find symbol

package com.teamtreehouse;

import java.io.Serializable; import java.util.ArraysList; 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(Treets 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 getWordsPrefixedWith("#");

} public List<String> getMentions() { return getWordsPrefixedWith("@"); } 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;
}

}

Dave Jindal
Dave Jindal
4,000 Points

Hey Jose,

first of all, try to be more precise with your errors. In this case returning the exact error message would be helpful in accurately answering your question.

I think, you have a typo in your import statement:

import java.util.ArraysList;         

this should be "java.util.ArrayList"

You should also check this line:

@Override public int compareTo(Treets other) {
 if (equals(other)) {
 return 0;
 }

I think the classtype is called Treet here instead of Treets.

The java compiler is actually pretty good at telling you where the errors are. If you look carefully it shows you the line, in which the error occured!

For example: symbol: class ArraysList location: package java.util Treet.java:9 error:cannot find symbol <--- Treet.java is the filename and ":9" is the line where to look at!

I hope this helped!

Cheers Dave

1 Answer

Jose Torres
PLUS
Jose Torres
Courses Plus Student 2,493 Points

Thanks Dave! great observation I did mistype them . I did as you recommended and the console worked perfectly!

Dave Jindal
Dave Jindal
4,000 Points

Your welcome. If you found my answer helpful, i'd be happy when you mark it/upvote :)