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 Packages

Now in the main method of Display.java, instantiate a new BlogPost.

Now in the main method of Display.java, instantiate a new BlogPost. Use System.out.printf to print out "This is a blog post: %s" and pass in the newly created BlogPost object to replace the string formatter..

com/example/BlogPost.java
package com.example;
public class BlogPost(){
}
  public static void main (String[]args){
  }
Display.java
import com.example.blogPost;
public class Display {
  public static void main(String[] args) {
  BlogPost blogPost= new  BlogPost();
  System.out.printf("This is a blog post: %s %n",blogPost);

    // Your code here...
}

}

6 Answers

blogPost.java

package com.example;

public class BlogPost {

}

display.java

import com.example.BlogPost;
public class Display {
  public static void main(String[] args) {

    BlogPost myeBlog = new BlogPost();
    System.out.printf("This is a blog post: %s", myeBlog);

  }
}

Not working

import com.example.BlogPost;

public class Display { public static void main(String[] args) { BlogPost blogPost = new BlogPost(); System.out.printf("This is a blog post: %s", blogPost);

} }

i just tried it and it's working, just try copy everything and paste, I have no idea why is not working because here it does

THANK YOU SOO MUCH

Have you try replace your blogpost.java with this i sent you?

YES BUT NOT WORKING

you have syntax error with your import statement

Display.java
import com.example.blogPost;

change it to com.example.BlogPost

NOT WORKING

also you don't have to type main method in BlogPost.java so remove this line

BlogPost.java
  public static void main (String[]args){
  }

THANK YOU SOO MUCH

import com.example.BlogPost; public class Display { public static void main(String[] args) {

    BlogPost anyName = new BlogPost();
    System.out.printf("This is a blog post: %s", anyName);

} }

// remember to create a public class on the BlogPost file or the class will not be accessible!!