Created
July 29, 2021 17:24
-
-
Save thehale/ce83ede36338486dd4957d5f8fca31f5 to your computer and use it in GitHub Desktop.
Sample program for https://stackoverflow.com/questions/68579674
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Scratch { | |
// Assign multiple double values from System.in | |
// without writing `nextDouble()` more than once. | |
public enum DoubleExample { | |
A, B, C; | |
public final double value; | |
private DoubleExample() { value = new Scanner(System.in).nextDouble(); } | |
} | |
// Entry point to demonstrate the example. | |
public static void main(String... args) { | |
System.out.println(DoubleExample.A.value); | |
System.out.println(DoubleExample.B.value); | |
System.out.println(DoubleExample.C.value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment