current position:Home>What's wrong with the scanner usage?

What's wrong with the scanner usage?

2022-02-03 01:40:18 CSDN Q & A

img

img

img

img


Shape Circle =new Circle(2,3) This can succeed , But I want to use Scanner Enter the program you want to enter . This is not Scanner What does the definition method mean ? What's wrong with me ? How to change ?




Refer to the answer 1:

It just blocks . How did you call




Refer to the answer 2:



Refer to the answer 3:

getDirm The method is Shape Methods defined in the interface , Scanner This method does not exist in the class , So the compilation failed .




Refer to the answer 4:



Refer to the answer 5:
Scanner input = new Scanner(System.in);        int a = input.nextInt();        int b = input.nextInt();        Shape shape =new Circle(a,b);        System.out.println(shape.getArea());        System.out.println(shape.getDirm());



Refer to the answer 6:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030140161015.html

Random recommended