0

why does this refer to small

enum Size{ SMALL, MEDIUM, LARGE, EXTRALARGE; public String getSize() { // this will refer to the object SMALL switch(this) { case SMALL: return "small"; case MEDIUM: return "medium"; case LARGE: return "large"; case EXTRALARGE: return "extra large"; default: return null; } } public static void main(String[] args) { // call getSize() // using the object SMALL System.out.println("The size of the pizza is " + Size.SMALL.getSize()); } }

10th Nov 2020, 8:36 PM
Manfred h
1 Antwort
0
Well I see you getting the Size of the Small enum collection
11th Nov 2020, 5:30 AM
George S Mulbah II
George S Mulbah II - avatar