Results 1 to 6 of 6
Thread: need help
- 11-13-2010, 06:34 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 15
- Rep Power
- 0
need help
please check this code it is compling but giving run time error
what is the problem with it please help meJava Code:public class Bicycle{ private int cadence; private int gear; private int speed; private int id; private static int numberOfBicycles = 0; public Bicycle(int startCadence, int startSpeed, int startGear){ gear = startGear; cadence = startCadence; speed = startSpeed; id = ++numberOfBicycles; } public int getID() { return id; } public static int getNumberOfBicycles() { return numberOfBicycles; } public int getCadence(){ return cadence; } public void setCadence(int newValue){ cadence = newValue; } public int getGear(){ return gear; } public void setGear(int newValue){ gear = newValue; } public int getSpeed(){ return speed; } public void applyBrake(int decrement){ speed -= decrement; } public void speedUp(int increment){ speed += increment; } }Last edited by Eranga; 11-14-2010 at 01:41 AM. Reason: code tags added
- 11-13-2010, 06:37 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 11-13-2010, 08:22 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 56
- Rep Power
- 0
Are you compiling it or running it? If you are compiling it, it will be a syntax error, not a runtime error. If you try to run this code, it won't. It is a cookie-cutter class and it does not have a "main" method. If it is a syntax error, tell us what line its on and we will help. But you will ALWAYS get a runtime error if you try to run this code.
- 11-14-2010, 01:46 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Two things to highlight over here.
1. Please use code tags when you are posting code segments here in the forum next time. Unformated codes are hard to read. If you don't know how to do it, check in my forum signature.
2. Without providing more details how can we answer to your questions. We don't know what the error message is. So please provide more details next time.
Did you run this code? I don't think so, because without a main how did you do that? (it's possible but we don't know weather you did it in another way without providing more details) So may be you end up with a compiletime error.
Could you please post the complete error message over here to see. So we can comment on it to fix your issues.
- 11-14-2010, 07:20 AM #5
Member
- Join Date
- Nov 2010
- Posts
- 15
- Rep Power
- 0
yeah i got the mistake
thank you all.
- 11-14-2010, 02:32 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you've solve the problem please mark the thread solved. It's really helpful to all other members. :)


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks