Java 8 Random - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Random class.

This code example shows how to use the following methods:
 
import java.util.Random; 
 
public class LongFieldDataBenchmark { 
 
    private static final Random RANDOM = new Random();
    private static final int SECONDS_PER_YEAR = 60 * 60 * 24 * 365;
 
    public static enum Data { 
        SINGLE_VALUES_DENSE_ENUM {
            public int numValues() { 
                return 1; 
            } 
            @Override 
            public long nextValue() { 
                return RANDOM.nextInt(16); 
            } 
        }, 
        SINGLE_VALUED_DENSE_DATE {
            public int numValues() { 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
        ConfigFactory.load("remotecreation")); 
    final ActorRef actor = system.actorOf(Props.create(CreationActor.class),
        "creationActor"); 
 
    System.out.println("Started CreationSystem");
    final Random r = new Random();
    system.scheduler().schedule(Duration.create(1, SECONDS),
        Duration.create(1, SECONDS), new Runnable() {
          @Override 
          public void run() { 
            if (r.nextInt(100) % 2 == 0) {
              actor.tell(new Op.Multiply(r.nextInt(100), r.nextInt(100)), null);
            } else { 
              actor.tell(new Op.Divide(r.nextInt(10000), r.nextInt(99) + 1),
                  null); 
            } 
          } 
        }, system.dispatcher());
  } 
} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: nextLong
    public static ByteBuffer guidAsBytes()
    { 
        StringBuilder sbValueBeforeMD5 = new StringBuilder();
        long time = System.currentTimeMillis();
        long rand = 0;
        rand = myRand.nextLong();
        sbValueBeforeMD5.append(s_id)
                        .append(":")
                        .append(Long.toString(time))
                        .append(":")
                        .append(Long.toString(rand));
 
        String valueBeforeMD5 = sbValueBeforeMD5.toString();
        return ByteBuffer.wrap(FBUtilities.threadLocalMD5Digest().digest(valueBeforeMD5.getBytes()));
    } 
 
    /* 
        * Convert to the standard format for GUID 
        * Example: C2FEEEAC-CFCD-11D1-8B05-00600806D9B6 
    */ 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: nextInt
        mPlayer.setDataSource("test:invoke_mock_media_player.so?url=ping");
 
        Parcel request = mPlayer.newRequest();
        Parcel reply = Parcel.obtain();
 
        int val = rnd.nextInt();
        request.writeInt(val);
        mPlayer.invoke(request, reply);
        assertEquals(val, reply.readInt());
   } 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: nextFloat
			return -1; 
		} 
	} 
 
	public static final float random(final float pMin, final float pMax) {
		return pMin + RANDOM.nextFloat() * (pMax - pMin);
	} 
 
	/** 
	 * @param pMin inclusive! 
	 * @param pMax inclusive! 
	 * @return 
	 */ 
	public static final int random(final int pMin, final int pMax) {
		return pMin + RANDOM.nextInt(pMax - pMin + 1);
	} 
 
	public static final boolean isPowerOfTwo(final int n) {
		return ((n != 0) && (n & (n - 1)) == 0);
	} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 Random Questions & Answers:

Other Java 8 Random Examples

15:	  private ObjectAnimator animation2;
16:	  private Button button;
17:	  private Random randon;
18:	  private int width;
19:	  private int height;
-
26:	    width = getWindowManager().getDefaultDisplay().getWidth();
27:	    height = getWindowManager().getDefaultDisplay().getHeight();
28:	    randon = new Random();
29:	
30:	    set = createAnimation();

Read More

12:				// shuffle is on - play a random song
13:				Random rand = new Random();
14:				currentSongIndex = rand.nextInt((songsList.size() - 1) - 0 + 1) + 0;
15:				playSong(currentSongIndex);
16:			} else{
-
12:				// shuffle is on - play a random song
13:				Random rand = new Random();
14:				currentSongIndex = rand.nextInt((songsList.size() - 1) - 0 + 1) + 0;
15:				playSong(currentSongIndex);
16:			} else{

Read More

24:		private static final int MAX_ATTEMPTS = 5;
25:	    private static final int BACKOFF_MILLI_SECONDS = 2000;
26:	    private static final Random random = new Random();
27:	
28:	    /**
-
24:		private static final int MAX_ATTEMPTS = 5;
25:	    private static final int BACKOFF_MILLI_SECONDS = 2000;
26:	    private static final Random random = new Random();
27:	
28:	    /**

Read More

338:	
339:		}
340:	
341:		/**
342:		 * When user starts moving the progress handler
-
338:	
339:		}
340:	
341:		/**
342:		 * When user starts moving the progress handler

Read More

See Code Examples for Java 8 Random Methods: