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 trialLeen Leenaerts
1,096 Pointsim getting errors
./com/example/BlogPost.java:32: error: cannot find symbol public List getExternalLinks() { ^ symbol: class List location: class BlogPost ./com/example/BlogPost.java:33: error: cannot find symbol List words = Arrays.asList(getWords()); ^ symbol: class List location: class BlogPost ./com/example/BlogPost.java:33: error: cannot find symbol List words = Arrays.asList(getWords()); ^ symbol: variable Arrays location: class BlogPost ./com/example/BlogPost.java:34: error: cannot find symbol List httpList = new ArrayList(); ^ symbol: class List location: class BlogPost ./com/example/BlogPost.java:34: error: cannot find symbol List httpList = new ArrayList(); ^ symbol: class ArrayList location: class BlogPost Note: JavaTester.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 5 errors
package com.example;
import java.io.Serializable;
import java.util.Date;
public class BlogPost implements Comparable<BlogPost>, Serializable {
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 int compareTo(BlogPost other) {
if (equals(other)) {
return 0;
}
return mCreationDate.compareTo(other.mCreationDate);
}
public String[] getWords() {
return mBody.split("\\s+");
}
public List <String> getExternalLinks() {
List <String> words = Arrays.asList(getWords());
List <String> httpList = new ArrayList<String>();
for (String word : words){
if (word.startsWith("http")) {
httpList.add(word);
}
}
return httpList;
}
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;
}
}
3 Answers
Iain Diamond
29,379 PointsHi Leen, It looks like you need to include libraries for
import java.util.List;
import java.util.ArrayList;
Hope this helps, iain
Leen Leenaerts
1,096 Pointsthanks it solved most problems but still 1 left:
./com/example/BlogPost.java:23: error: cannot find symbol List words = Arrays.asList(getWords()); ^ symbol: variable Arrays location: class BlogPost Note: JavaTester.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
Iain Diamond
29,379 PointsArrays is another library you'll need to include. Here's a link to the official documentation.
http://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html
Smart Ganyaupfu
3,129 PointsPeople I don't know where I am missing it.I need help on the for each loop. I am getting errors on my getTileCount method, it is saying I forgot to create the method.
~public class ScrabblePlayer { private String mHand;
public ScrabblePlayer() { mHand = ""; }
public String getHand() { return mHand; }
public void addTile(char tile) { // Adds the tile to the hand of the player mHand += tile; }
public boolean hasTile(char tile) { return mHand.indexOf(tile) > -1; } public int getTileCount(){ int counter = 0; for(char letter : mHand.toCharArray()){ counter++; } return counter;
} }