I made function 'warn' in line 17 whose parameter is enum Shape. Why is it warning about visibility scope and how can I fix it?
import java.util.Scanner;
public class AreaCalculator {
enum Shape {TRIANGLE, RECTANGLE, CIRCLE}
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
String str = scanner.next();
while (!str.equals("quit")){
str = str.toUpperCase();
warn(Shape.valueOf(str));
}
}
public static void warn(Shape shape) { //warning
}
IntelliJ recommends generate overloaded method with default parameter values like following code.
public static void warn(){
warn(null);
}
But I think it doesn't look intuitive.
enum Shape
public
, orwarn
notpublic
. – AlbuquerqueShape
public, or makewarn
package-private (or private). – Downstroke