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 Packages

Bhawani Shankar
Bhawani Shankar
954 Points

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

  }
}
Sean M
Sean M
7,344 Points

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

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

Fahad Mutair
Fahad Mutair
10,359 Points

you have syntax error with your import statement

Display.java
import com.example.blogPost;

change it to com.example.BlogPost

Fahad Mutair
Fahad Mutair
10,359 Points

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

BlogPost.java
  public static void main (String[]args){
  }
Gonzalo Torres del Fierro
PLUS
Gonzalo Torres del Fierro
Courses Plus Student 16,751 Points

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!!