Generally, a class corresponds to an associated object, and its method is the same as the static method in Java. For example, the bigint companion object of the bigint class has a method probableprime that generates random prime numbers of specified digits, run the following code in repl:
Object helloworld {def main (ARGs: array [String]) {for (I <-1 to 10) {println (bigint. probableprime (10, scala. util. random ));}}} |
The result is as follows:
523977839911977593599809809883 process finished with exit code 0 |
In my estimation, it may be the first parameter. 10 specifies the binary number of digits, SO 2 ^ 10 = 1024, that is, the maximum random prime number produced by this function is 1024. Here, random is a single-instance random number generator object, and this object is in Scala. defined in the util package. This is one of the few scenarios where the singleton object is better than the class.
How to set the intellijidea font to file-setting-ide settings-Editor-colors & fonts-font (save... A scheme) font size can also be changed here. How can I set the shortcut key of intellijidea to the shortcut key of Eclipse? I switched it from eclipse. In intellij idea, you can set it to the shortcut key style of eclipse. It may be a little different. Just configure it as needed. Set the shortcut key and open the settings (CTRL + ALT + S) to search for keymap. \ Scala \ bin \ scala. BAT should not be available at this time ). It should be noted that it is best not to install Scala to a path with spaces. Otherwise, when running the "Scala-version" command, it may be reported that "\ Scala \ bin \ Scala should not be available at this time. BAT )." Error message.