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

Thale van der Sluijs
Thale van der Sluijs
1,756 Points

19 errors?!

If you go to the video before the challenge. I wanted to run my code when I was done and I got 19 errors, but first when I had to fix one thing that Craig Dennis did the too it said there was only 1 error... Can someone help me?

Could you post your code and the errors too, if possible?

7 Answers

Sorry, I should have seen that. The % markers need to be inside the string. They act as placeholder where the values of your variables are inserted; string interpolation.

System.out.printf("This is a new Treet:  %s %n", treet);    

I moved your end quote to encompass the %s (string insert) and %n (newline). That should clear your errors.

Steve.

Thale van der Sluijs
Thale van der Sluijs
1,756 Points

thanks! yeah i should have known that too

Hiya,

I have added three comments in your code - can you correct those then post back what errors remain, please? There are multiple errors on the compile being caused by single code issues.

Let's start with those that I can easily see, then work out what's left after correcting those three.

Steve.

OK - in your definition; you have called your creationDate a String not a Date. So, change this right at the start of your Treet class:

private String mCreationDate;

to:

private Date mCreationDate;

And, I think that sorts you out. Please let me know how you get on.

Steve.

Thale van der Sluijs
Thale van der Sluijs
1,756 Points

These are my codes: My Example.java:

import java.util.Date;
import com.teamtreehouse.Treet;

public class Example {

 public static void main(String[] args){
   Treet treet = new Treet("craigsdennis",
                          "yeah ohke",
                          new date(1448104984000L) // should be Date (capital D)
                          );
   System.out.printf("This is a new Treet:  %s %n", treet);   
 }  
}

and this is my Treet.java:

package com.teamtreehouse;

import java.util.Date;

public class Treet{
   private String mAuthor;
   private String mDestcription; // typo of mDescription
   private String mCreationDate;

  public Treet(String author, String description, Date creation date) { // should be creationDate not creation date
    mAuthor = author;
    mDescription = description;
    mCreationDate = creationDate;

}
  public String getAuthor() {
    return mAuthor;
  } 

  public String getDescription(){
   return mDescription; 
  }
  public Date getCreationDate(){
    return mCreationDate;
  }
}
Thale van der Sluijs
Thale van der Sluijs
1,756 Points

and this are the errors:

./com/teamtreehouse/Treet.java:10: error: ')' expected                
  public Treet(String author, String description, Date creation date) 
{                                                                     
                                                               ^      
./com/teamtreehouse/Treet.java:10: error: illegal start of type       
  public Treet(String author, String description, Date creation date) 
{                                                                     
                                                                    ^ 
./com/teamtreehouse/Treet.java:10: error: <identifier> expected       
  public Treet(String author, String description, Date creation date)
{                                                                     

 ^                                                                    
./com/teamtreehouse/Treet.java:11: error: illegal start of type       
    mAuthor = author;                                                 
            ^        
./com/teamtreehouse/Treet.java:12: error: <identifier> expected       
    mDescription = description;                                       
                ^                                                     
./com/teamtreehouse/Treet.java:13: error: <identifier> expected       
    mCreationDate = creationDate;                                     
                 ^                                                    
./com/teamtreehouse/Treet.java:16: error: class, interface, or enum ex
pected                                                                
  public String getAuthor() {                                         
         ^              
./com/teamtreehouse/Treet.java:18: error: class, interface, or enum ex
pected                                                                
  }                                                                   
  ^                                                                   
./com/teamtreehouse/Treet.java:20: error: class, interface, or enum ex
pected                                                                
  public String getDescription(){                                     
         ^                                                            
./com/teamtreehouse/Treet.java:22: error: class, interface, or enum ex
pected                                        
            }                                                                   
  ^                                                                   
./com/teamtreehouse/Treet.java:12: error: cannot find symbol          
    mDescription = description;                                       
    ^                                                                 
  symbol:   class mDescription                                        
  location: class Treet                      

 ./com/teamtreehouse/Treet.java:13: error: cannot find symbol          
    mCreationDate = creationDate;                                     
    ^                                                                 
  symbol:   class mCreationDate                                       
  location: class Treet                                               
Example.java:11: error: cannot find symbol                            
                          new date(1448104984000L)                    
                              ^                                       
  symbol:   class date                                                
  location: class Example 
./com/teamtreehouse/Treet.java:10: error: missing method body, or decl
are abstract                                                          
  public Treet(String author, String description, Date creation date) 
{                                                                     
         ^                                                            
./com/teamtreehouse/Treet.java:12: error: cannot find symbol          
    mDescription = description;                                       
                   ^                                                  
  symbol:   variable description                                      
  location: class Treet        
./com/teamtreehouse/Treet.java:13: error: cannot find symbol          
    mCreationDate = creationDate;                                     
                    ^                                                 
  symbol:   variable creationDate                                     
  location: class Treet                                               
19 errors    ```
Thale van der Sluijs
Thale van der Sluijs
1,756 Points

This are the errors left:

<p> Example.java:11: error: cannot find symbol                            
   System.out.printf("This is a new Treet:  "%s %n, treet);           
                                                                         ^                       
  symbol:   variable s                                                
  location: class Example                                             
Example.java:11: error: cannot find symbol                            
   System.out.printf("This is a new Treet:  "%s %n, treet);           
                                                                              ^                    
  symbol:   variable n                                                
  location: class Example       
./com/teamtreehouse/Treet.java:13: error: incompatible types: Date can
not be converted to String                                            
    mCreationDate = creationDate;                                     
                                 ^                                                 
./com/teamtreehouse/Treet.java:24: error: incompatible types: String 
cannot be converted to Date  
  return mCreationDate;                                             
             ^                                                          
4 errors
</p> ```

The arrows are pointing wrong. I don't know why but they have to point here:
1. at %s
2. at %n
3. at creationDate
4. at mCreationDate
Thale van der Sluijs
Thale van der Sluijs
1,756 Points

Now There are 2 errors left:

Example.java:11: error: cannot find symbol
System.out.printf("This is a new Treet: "%s %n, treet); ^

symbol: variable s
location: class Example
Example.java:11: error: cannot find symbol
System.out.printf("This is a new Treet: "%s %n, treet);
^
symbol: variable n
location: class Example 2 errors

And the Arrows point wrong again.... The first one has to point at the %s And the second one at the %n