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

Android Build a Simple Android App (2014) Improving Our Code Creating a Class

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

What is wrong with my code?

What is wrong with this code,

public class PictureBook {}


public String mTitle {}

Also, shouldn't the first line read public class Picturebook {};

it wouldn't accept the semicolon at the end of it it keeps telling

class interface or enum expected.

Help?

Not indenting the second line didn't work as well.

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Rob,

You current have your mTitle property defined outside the class; not within it like the task is asking for and have also given it curly braces which won't work, simply change it like the below and it will work as expected.

public class PictureBook {
  public String mTitle;
}

Also, shouldn't the first line read public class Picturebook {};

Classes don't require semi-colons as they're encapsulated code blocks meaning it only requires you to use semi-colons for the properties you define within the class, any code before or after the class isn't affected by not having a semi-colon there.