Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,184,240 members, 7,923,197 topics. Date: Friday, 16 August 2024 at 08:12 PM

Help Debug This Java Code - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help Debug This Java Code (1317 Views)

Please Help Me To Test And Debug This GSM Number Extractor Logic / Assembly Language/debug Wahala / Improve The Speed Of This Java Code. (2) (3) (4)

(1) (Reply) (Go Down)

Help Debug This Java Code by buster(m): 6:50pm On Dec 19, 2014
Hello Java Programmers

After running the code below, i got no output for the program[img][/img]:

class Box {

double width;
double height;
double depth;
Box() {
}
Box(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
void getVolume() {
System.out.println("Volume is : " + width * height * depth);
}
}

public class MatchBox extends Box {

double weight;
MatchBox() {
}
MatchBox(double w, double h, double d, double m) {
super(w, h, d);
weight = m;
}
public static void main(String args[]) {
MatchBox mb1 = new MatchBox(10, 10, 10, 10);
mb1.getVolume();
System.out.println("width of MatchBox 1 is " + mb1.width);
System.out.println("height of MatchBox 1 is " + mb1.height);
System.out.println("depth of MatchBox 1 is " + mb1.depth);
System.out.println("weight of MatchBox 1 is " + mb1.weight);
}
}

Re: Help Debug This Java Code by nollyj: 7:17pm On Dec 19, 2014
There is nothing wrong with the code

Re: Help Debug This Java Code by Javanian: 7:23pm On Dec 19, 2014
Code works. You are probably getting the packaging wrong. Make sure they are in the same package.
Re: Help Debug This Java Code by buster(m): 4:58pm On Dec 20, 2014
i tried compiling again and am told cannot find mainclass. Can i see d screen capture of the Box.java file and did u make anyone main class?
nollyj:
There is nothing wrong with the code
Re: Help Debug This Java Code by Bossman(m): 6:36pm On Dec 22, 2014
As others mentioned - your code looks fine. Make sure Box and MatchBox are in the same package. You may want to declare Box as "public", otherwise it will be put in the default package. Good luck!

(1) (Reply)

Must My Array Or Pointer Allocation Have A Limit In C Or C++? / PHP Programmers:Name Your Best HMVC Framework / 2016 Niit's Easter Promo ?need Advice

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.