₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,324,995 members, 8,419,855 topics. Date: Thursday, 04 June 2026 at 03:11 AM

Toggle theme

Help Debug This Java Code - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp Debug This Java Code (1406 Views)

1 Reply (Go Down)

Help Debug This Java Code by buster(op): 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(op): 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

Please Help Me To Test And Debug This GSM Number Extractor LogicAssembly Language/debug WahalaImprove The Speed Of This Java Code.234

C# Keylogger With Fake Virus Windows Alert [undetectable]C++: Please If You've Used That C++ Web Cartoon Maker - Help MeFor Real Developers