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 Getting There Class Review

naga bonar
naga bonar
3,338 Points

error: constructor Treet in class Treet cannot be applied to given types

Hi, i've follow all the code from the video. but when i run the Example, i got an error like below: Example.java:8: error: constructor Treet in class Treet cannot be applied to given types;
Treet treet = new Treet(
^
required: no arguments
found: String,String,Date
reason: actual and formal argument lists differ in length
1 error

my Example.java code is like below: import java.util.Date;

import com.teamtreehouse.Treet;

public class Example {

public static void main(String[] args) { Treet treet = new Treet( "Bonar", "coba coba coba coba", new Date(1470837243000L) ); System.out.printf("This is a new Treet: %s \n", treet); } }

and my Treet.java code is like below: package com.teamtreehouse;

import java.util.Date;

public class Treet{ private String mAuthor; private String mDescription; private Date 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 mCreationDate(){
    return mCreationDate;
}

}

Please help me if i misscode something. Really appreciate your help, thank you.

3 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Are you working in Workspaces. I just started workspace from the video you are on. Typed in workspace console javac Example.java and then java Example - worked like a charm. Do you do the same?

naga bonar
naga bonar
3,338 Points

Yes I work in Workspace. I tried from scratch with the same code and it's working. I wonder why it didn't work.

Thank you anyway, Alex.

naga bonar
naga bonar
3,338 Points

Hi Alex,

Sorry that my post is so messy, i still don't know how to post it properly. But, there is "package com.teamtreehouse" right after "and my Treet.java code is like below:"

Thank you..

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Does your code look like this? Example.java:

package com.teamtreehouse;

import com.teamtreehouse.Treet;

import java.util.Date;

public class Main{

    public static void main(String[] args) {
        Treet treet = new Treet( "Bonar", "coba coba coba coba", new Date(1470837243000L) );
        System.out.printf("This is a new Treet: %s \n", treet);
    }
}

And Treet.java:

package com.teamtreehouse;

import java.util.Date;

public class Treet {
    private String mAuthor;
    private String mDescription;
    private Date 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 mCreationDate(){
        return mCreationDate;
    }
}

And they are both in the same folder, in the same package right?