0

It says I have one problem with my method calling

It's says cannot find area() 😱 class Triangle{ double base; double height; double area(){ return base*height*0.5; } } public class Triangle1 { public static void main(String[] args) { Triangle T1=new Triangle(); T1.base=8; T1.height=20; System.out.println("the answer is"+area()+"cm"); } }

17th Feb 2022, 12:04 PM
Tony Jadesola
2 Answers
+ 1
You need to call the method on the object. System.out.println("the answer is "+T1.area()+" cm");
17th Feb 2022, 12:07 PM
Avinesh
Avinesh - avatar
0
Avinesh thanks I just realized it before your message entered am so grateful 🙂
17th Feb 2022, 12:08 PM
Tony Jadesola