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 Organizing Data Serialization

ninaddeshpande
ninaddeshpande
6,158 Points

Error : cannot find symbol (Treet) in Treets.java!

Even after importing com.teamtreehouse package, compilation fails with the following error: Treets.java:7: error: cannot find symbol
public static void save(Treet[] treets){
^
symbol: class Treet
location: class Treets
1 error

Following is my source code (Treets.java):

package com.teamtreehouse;
import java.io.*;

public class Treets {
  public static void save(Treet[] treets){
    try (
          FileOutputStream fos = new FileOutputStream(treets.ser);
          ObjectOutputStream oos = new ObjectOutputStream(fos);
    ){
      oos.writeObject(treets);
    }
    catch(IOException ioe){
      System.out.println("Ooh! Error occured while writing object: "+ioe.getMessage());
    }
  }
}

2 Answers

You have a spelling or typo error. Learn to read the compiler error. The 7 means line 7. "can not find symbol" means Treet class doesn't exist (because you named it Treet*s*)

Treets.java:7: error: cannot find symbol
public static void save(Treet[] treets){
                        ^
symbol: class Treet 
location: class Treets

Solution: Add an 's' to make it Treets[] or rename your Treets.java (and class) to Treet.java.

ninaddeshpande
ninaddeshpande
6,158 Points

Thanks for the response. However, it is not a typo. Treet is altogether different class present in com.teamtreehouse package. I am trying to save its array of objects (Treet[] treets) using serialization in that save method. com.teamtreehouse package contains Treet.java and Treets.java.

Not sure if related to your error, but "treets.ser" should have quotes around it like in the video.

FileOutputStream fos = new FileOutputStream("treets.ser");

Also, did you put "import com.teamtreehouse.Treets;" in Example.java?