Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

John Hammett
6,173 PointsHow do I add a double method??? Please answer!!!!!
Please Help!
public class Forecast() {
}
1 Answer

Harry James
14,780 PointsHey 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 :)
Victor Learned
6,976 PointsVictor Learned
6,976 PointsAre 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.