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 Weather App (2015) Exploring an API Android Warm-Up

How do I add a double method??? Please answer!!!!!

Please Help!

Forecast.java
public class Forecast() {

}
Victor Learned
Victor Learned
6,976 Points

Are you asking how to create a method that returns a double? If so just place this within your class. You can also add parameters as well. I would recommend taking a few of the Java programming courses if you aren't familiar with how methods work.

public double GiveMeADouble()
{
     double test = 0.0;

     return test;

}

1 Answer

Harry James
Harry James
14,780 Points

Hey John!

I believe you must've mis-read the question. We're creating member variables rather than classes so, we create these in the normal format of a variable:

public String myString = "This is a string";

So, you'll need to update the visibility (See the question), the variable type (Which should be either int or double (See the question to know which one to use)) and prefix with m for a member variable. Also, you don't need to set a value for the variable so, just end it with a ;.

Also, be sure to remove them brackets from your class declaration! We don't use brackets next to the class name - we use constructors for this instead but, you don't need to worry about this for the Code Challenge.


Hopefully, this should make sense now but, if there's still something you don't understand, give me a shout :)