Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Selection Does not contain a main type?
Cameron Jones
Greenhorn
Posts: 1
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Car { public class CarDemo { public void main(String[] args) { Car Cobalt = new Car(); Car Cobalt2 = new Car(); Cobalt.faster(); Cobalt2.stop(); } } int intial_speed = 100; int distance = 200; int deacceleration = 50; int acceleration = 10; int time = 5; int accelerate; int stoppingDistance; void faster() { accelerate = time * acceleration + intial_speed; System.out.println(accelerate+"km/ph^2"); } void stop() { stoppingDistance = distance/deacceleration; System.out.println(stoppingDistance+"m"); } void printstates() { System.out.println(accelerate+"kmph" ); } }
what'd I do wrong?
I know I'm a newb, and this is simple...
Tina Smith
Ranch Hand
Posts: 208
9
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The method signature you are looking for is
public static void main( String[] args ) { ... }
You missed the static keyword, which allows the main method to be run without instantiating the Car class.
P.S. Please use the code tags when posting code.
Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
Campbell Ritchie
Marshal
Posts: 79177
377
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Welcome to the Ranch
I have changed the quote tags to code, and you can see how much better it looks.
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Is Java too difficult for me? Trying to learn with Head first Javabook
[enthuware] OO Concepts - Shadowing vs. overriding
interface example
Confused with output
OVERLOAD&OVERRIDE
More...