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 Organizing Data Splitting Strings

cannot find symbol "word"

if I turn (word) into ("word") I get no error but it spells put "word" When i take out the quotes I get an error saying it cannot find the symbol System.out.println(word); ^ import java.util.Date;

import com.teamtreehouse.Treet;

public class Example{

public static void main (String[] args){ Treet treet = new Treet( "DMcGee20", "This is a test of a tweet that I have not actually made #Twitter.", new Date(1421849732000L) ); System.out.printf("This is a new treet: %s %n", treet); System.out.println("The words are: "); for (String word: treet.getWords());{ System.out.println(word); } } }

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; }

@Override public String toString(){ return "Treet: \"" + mDescription + "\" -@" + mAuthor; }

public String getAuthor(){ return mAuthor; }

public String getDescription(){ return mDescription; }

public Date getCreationDate(){ return mCreationDate; }

public String[] getWords(){ return mDescription.toLowerCase().split("[^\w#@']+"); }

}

Mike Papamichail
Mike Papamichail
4,883 Points

Please surround your java code like this so that it is easier to read:

Try adding a reply here and you will see below the white Box a bold text saying: Markdown Cheatsheet.

Click on that :D !

Lukasz Walczak
Lukasz Walczak
6,620 Points

Hi. Dylan.

Pls see below for solution. I've checked it and it works fine.

       for (String word: treet.getWords()); //notice the semicolon here 
        {                                 //remove it and it will works
         System.out.println(word); 
        }