How to Get Main output into Common() method in Java?

Is there a way to get random numbers from the C++ srand() method in Java?

  • I am trying to make a Java implementation of the Microsoft FreeCell card game and this means I need to generate the order of the deck using exactly the same method that Microsoft ...show more

  • Answer:

    Java has JNI and JNA. JNI is Java Native Interface. You write wrappers for the C++ functions you want to expose to Java. JNA is the same thing, except the coding for the C++ wrappers is linked as a 'lazy' reference.

L4NKOYVSJZZFR4D65GZ3BWLUPM at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Java has ways of getting random numbers 1) There's the method in the Math class random(). 2) There's also a Random class. Since rand() returns ints and you usually use % to get the range that you want, you'll probably want to define a Random object import java.util.Random; Random rand = new Random(); to get and int between 0 and k-1: int val = rand.nextInt(k);

modulo_function

For crying out loud, doesn't Java have a random number function?

ok_ranger

i don't see why you don't just use java's method of generating numbers, whatever that is, it should be the same algorithm, or almost the same as the random number is based on the current time on your computer

Matias

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.