?? 1: java.lang ?? Math ????? random() ???? ???? ?? ??
?? ???? java? ? ??? ???? ?? ??? MyRandom???. ???:
public class MyRandom { public static void main(String[] args) { int radom = (int)(Math.random()*10); System.out.println(radom); } }
Math.random()? 0? 1 ??? ??? ???? ?????.
0?? 9 ??? ??? ????? ??? ?????. (int)(Math.random()*10)
(int)(Math.random()*10)
產(chǎn)生一個1~10之間的整數(shù)則可以寫著:(int)(Math.random()*10 + 1)
以此類推:產(chǎn)生一個0~n之間的數(shù)就應(yīng)寫作:Math.random()*n
取出一個指定長度大小的隨機正整數(shù):
public static int buildRandom(int length) { int num = 1; double random = Math.random(); if (random < 0.1) { random = random + 0.1; } for (int i = 0; i < length; i++) { num = num * 10; } return (int) ((random * num)); }
方法二:調(diào)用java.util下面Random類,此類的實例用于生成偽隨機數(shù)流,產(chǎn)生一個隨機整數(shù),則調(diào)用該類的nextInt()方法,使用Random類之前,則在包下導入java.util.Random
,代碼如下:
import java.util.Random; public class MyRandom { public static void main(String[] args) { Random rand = new Random(); int rInt = rand.nextInt(10); System.out.println(rInt); } }
其中Random rand = new Random()
是創(chuàng)建一個新隨機數(shù)生成器;rand.nextInt(int n)
(int )(Math.random()*10 + 1)
??: 0? n ??? ??? ????? ??? ?? ???? ???: Math.random()*n</ code ><p></p>??? ??? ??? ?? ????:<p><pre class='brush:php;toolbar:false;'>public class MyRandom {
public static void main(String[] args) {
int n = 20;
Random rand = new Random();
boolean[] bool = new boolean[n];
int randInt = 0;
for(int i = 0; i < 6 ; i++) {
do {
randInt = rand.nextInt(n);
}while(bool[randInt]);
bool[randInt] = true;
System.out.println(randInt);
}
}
}</pre>?? 2: java.util ???? Random ???? ?????. ? ???? ????? ?? ?? ???? ???? ??? ??? ???? ? ?????. ? ???? Random ???. NextInt() ???, Random ???? ???? ?? ??? ??? <code>java.util.Random
? ??????. ??? ??? ????: Java??? ??? ?? ?? ????? ??? ?? ??? ?????. ??????? ?? 20?? ??? 6?? ?? ?? ??? ??? ???? ?? ???????. ??rrreee??? ? ??? ?? ??? ???? ?? ?? ??? ?????. ?? ? ??? ??? ??? ?? ?? ???? ??? ??? ?? ???. ??? ??? ???? ?? do...while ??? ???? ?? ???? ??? ?????. ???? ?? ?????. ?????? ????: ??Java ?? ????????? ??? Java?? ??? ??? ???? ? ???? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

JDBC ????? ???? ????? ?? ?? ?? ??? ?? ?? ??? ?? ? ?? ??? ?? ?? ?? ??? ???????. 1. ????? ????? Conn.SetAutoCommit (False)?? ??????. 2. ??? ? ????? ?? ?? SQL ??? ?????. 3. ?? ??? ??? ?? Conn.commit ()?? ???? ??? ???? ???? ?? ??? ???? Conn.Rollback ()?? ??????. ???, ? ??? ???? ????, ??? ???? ????, ?? ??? ??? ?? ??? ??? ???? ? ???????. ?? ?? ?? ???? ????? ??? ???? ?? ?? ???? ???? ??? ????? ?? ??? ??? ? ?? ???? ?? ????.

?? ?? ? ?? ???? ???? ?? Java.Time ???? ???? ??????. 2. LocalDate, LocalDateTime ? LocalTime? ?? ?? ??? ??? ?????. 3. () ???? ???? ?? ??? ??? ????. 4. ???/???? ??? ???? ??? ????? ??? ??????. 5. ZonedDateTime ? Zoneid? ???? ???? ??????. 6. DateTimeFormatter? ?? ?? ? ?? ?? ?? ???; 7. ??? ?? ?? ?? ??? ????? ?? ??????. ?? Java? ?? ??? ???? ??? ??? ???? Java.Timeapi ??? ?? ??? ???????.

Pre-FormancetArtUptimeMoryUsage, Quarkusandmicronautleadduetocompile-timeprocessingandgraalvsupport, withquarkusoftenperforminglightbetterine serverless sinarios.2.thyvelopecosyste,

NetworkPortSandfirewallsworkTogetToenableCommunication whileensuringsecurity.1.networkportSarevirtualendpointsnumbered0–65535, Withwell-nownports like80 (http), 443 (https), 22 (ssh) ? 25 (smtp) ?? (specservices

Java 's Garbage Collection (GC)? ???? ???? ???? ??????, ?? ? ??? ??? ? ??? ??? ??? ??? ????. 1.GC? ?? ?? (? : ?? ??, ?? ???, ?? ?? ?)?? ??? ???? ????, ?? ? ??? ??? ???? ?????. 2. ?? ???? ????? ????, ?? ?? ??? ??? ???? ?? ??? ??????. 3. ?? ?? ?? ?? : ??? ?? (Eden, S0, S1)? ?? ????? ?????. ??? ??? ?? ? MajorGC? ???? ? ??? ? ????. Metaspace? ??? ?? ???? ?????. 4. JVM? ??? GC ??? ?????. SerialGC? ??? ?? ????? ?????. ParallelGC? ???? ??????. CMS? ?? ???

GradleisBetTerChoiceFormostNewProjectSduetoitssuperiorflexible, Performance, and ModernToolingsupport.1.Gradle'Sgroovy/kotlindslismoreConcisENDEXPRESSIVETHANMAVEN'SVOSEXML.2.GradleOutsMaveninbuildweedweedweedweedweedweedweedweedweedweedweedweedweedweede

DEFER? ??? ???? ?? ??? ??? ???? ? ?????. ?? ??? ?? ? ? ?? ????, ??? ??? ? ?? ?? (LIFO)? ??? ?????. 1. ?? ??? ??? ? ??? ?????. 2. ?? ??? ?? ??? ??? ????? ?????. 3. ?? ? ?? ?? ??? ? ????. 4. ??? ?????? ??? ??? ???? ?????. 5. ?? ??? ???? ?? ??? ?? ??? ?????. ??? ??? ?? ?? ? ???? ???? ? ????.

??? htmlinput ??? ???? ??? ???? ????? ??? ??? ?? ??? ???? ???? ? ????. 1. ???, ???, ??, ?? ? ??? ?? ??? ??? ?? ?? ?? ??? ???? ???? ??? ? ???? ??? ? ????. 2. HTML5? ?????? ??? ? ?? ?? ??? ?? ? ??? URL, ??, ?? ? ??? ?? ??? ??? ??????. 3. ?? ?? ? ? ??? ??? ???? ?? ??? ???? ???? ?? ???? ?? ???? ???? ?? ? ? ??? ?? ???????.
