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 trialtatenda passmore
5,773 Pointswhat wrong with my code l am stuck guys package com.example; import java.util.Date;
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;
}
@Override public String toString(){ return "BlogPost: \""+mTITLE + "\" -@" + mAUTHOR; } } 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;
}
11 Answers
George Sideris
Courses Plus Student 3,712 PointsTry to import : import java.util.*;
tatenda passmore
5,773 Pointsl saw a chain of errors
tatenda passmore
5,773 Points./com/example/BlogPost.java:2: error: class, interface, or enum expected import : import java.util*; ^
George Sideris
Courses Plus Student 3,712 PointsIf you want post all code ...
tatenda passmore
5,773 Pointsthe errows
^
./com/example/BlogPost.java:2: error: expected
import : import java.util;
^
./com/example/BlogPost.java:2: error: ';' expected
import : import java.util;
^
./com/example/BlogPost.java:2: error: class, interface, or enum expected
import : import java.util;
^
./com/example/BlogPost.java:2: error: class, interface, or enum expected
import : import java.util;
^
./com/example/BlogPost.java:24: error: class, interface, or enum expected
public String getAuthor() {
^
./com/example/BlogPost.java:26: error: class, interface, or enum expected
}
^
./com/example/BlogPost.java:28: error: class, interface, or enum expected
public String getTitle() {
^
./com/example/BlogPost.java:30: error: class, interface, or enum expected
}
^
./com/example/BlogPost.java:32: error: class, interface, or enum expected
public String getBody() {
^
./com/example/BlogPost.java:34: error: class, interface, or enum expected
}
^
./com/example/BlogPost.java:36: error: class, interface, or enum expected
public String getCategory() {
^
./com/example/BlogPost.java:38: error: class, interface, or enum expected
}
^
./com/example/BlogPost.java:40: error: class, interface, or enum expected
public Date getCreationDate() {
^
./com/example/BlogPost.java:43: error: class, interface, or enum expected
}
^
./com/example/BlogPost.java:21: error: cannot find symbol
return "BlogPost: \""+mTITLE + "\" -@" + mAUTHOR;
^
symbol: variable mTITLE
location: class BlogPost
./com/example/BlogPost.java:21: error: cannot find symbol
return "BlogPost: \""+mTITLE + "\" -@" + mAUTHOR;
^
symbol: variable mAUTHOR
location: class BlogPost
17 errors
William Li
Courses Plus Student 26,868 Pointsedited the post for proper code formatting.
tatenda passmore
5,773 Pointspackage com.example; import : import java.util; 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;
}
@Override public String toString(){ return "BlogPost: \""+mTITLE + "\" -@" + mAUTHOR; } } 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;
}package com.example; import : import java.util; 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;
}
@Override public String toString(){ return "BlogPost: \""+mTITLE + "\" -@" + mAUTHOR; } } 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;
}
tatenda passmore
5,773 Pointspackage com.example; import : import java.util; 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;
}
@Override public String toString(){ return "BlogPost: \""+mTITLE + "\" -@" + mAUTHOR; } } 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;
}
tatenda passmore
5,773 Pointsi am falling to sen the whole code l wil try again
George Sideris
Courses Plus Student 3,712 PointsIf you could tell us in which part of your cource you are ... I think in all cources you don't need to import anything ...
tatenda passmore
5,773 Pointson java objects the question Override the toString method from java.lang.Object and make it return the following information: "BlogPost: TITLE by AUTHOR"
George Sideris
Courses Plus Student 3,712 PointsSorry I can't find the question ... But you should check the brackets and try to not @OVERRIDE the method toString :
public String toString() { return "Text "; }