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
Benjamin Young
5,881 PointsI still cannot understand why I am running into this issue pertaining to Java
This is the error I am being alerted to: javac Example.java && java Example./com/teamtreehouse/Treet.java:13: error: incompatible types: Date cannot be converted to String mCreationDate = creationDate; ^ ./com/teamtreehouse/Treet.java:22: error: incompatible types: String cannot be converted to Date return mCreationDate;
And this is my actual code in Treet.java:
package com.teamtreehouse;
import java.util.Date;
public class Treet {
private String mAuthor;
private String mDescription;
private String mCreationDate;
public Treet(String author, String description, Date creationDate) {
mAuthor = author;
mDescription = description;
mCreationDate = creationDate;
}
public String getAuthor() {
return mAuthor;
}
public String getDescription() {
return mDescription;
}
public Date getCreationDate() {
return mCreationDate;
}
}
And here is my code from Example.java:
import java.util.Date;
import com.teamtreehouse.Treet;
public class Example {
public static void main(String[] args) {
Treet treet = new Treet(
"craigdennis",
"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(1421849732000L)
);
System.out.printf("This is a new Treet: %s %n", treet);
}
}
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! I feel fairly sure that this line:
private String mCreationDate;
should be this:
private Date mCreationDate;
In all other parts of your code, it references mCreationDate as being of type Date. But in your initial declaration in your class you have it as type String. Hope this helps!
Benjamin Young
5,881 PointsBenjamin Young
5,881 PointsThank you! I was kicking myself when after I noticed that simple error. Much appreciated!