Mega Code Archive

 
Categories / Java / Language Basics
 

Initializing interface fields with non-constant initializers

// : c08:RandVals.java // Initializing interface fields with non-constant initializers. // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002 // www.BruceEckel.com. See copyright notice in CopyRight.txt. import java.util.Random; public interface RandVals {   Random rand = new Random();   int randomInt = rand.nextInt(10);   long randomLong = rand.nextLong() * 10;   float randomFloat = rand.nextLong() * 10;   double randomDouble = rand.nextDouble() * 10; } ///:~