0

Error i am not getting.can anyone find it.

public class Box { double ht,wt,dp; Box(double h,double w,double d) { double h=ht; double w=wt; double d=dp; } double vol() { return ht*wt*dp; } } class Boxdemo { public static void main(String[] args) { Box ob=new Box (10,20,30); double vol (); vol =ob.vol(); System.out .println ("volume="+vol); } }

7th Nov 2016, 5:40 PM
MSK
MSK - avatar
2 Respostas
0
remove () while declaring vol in main function. you are using vol as variable not function.
7th Nov 2016, 7:18 PM
Amit Gupta
Amit Gupta - avatar
0
I have used it both as function and variable so it was giving an error now its running as i used it both with same name.Anyways thanks.
13th Nov 2016, 6:28 AM
MSK
MSK - avatar