###### tags: `Java 學習筆記` # Java 學習筆記 - 1-7: 亂數隨機 & 跳脫 ## 隨機亂數 ```java= public class MainClass { public static void main(String[] args) { Scanner sc = new.Scanner(System.in); double r = Math.random(); int r = (int)(Math.random() * 10); } } ``` * double + Math.random() 會隨機產生 0 ~ 1 之間的 double (預設) * int + random() 需要轉型並乘上 10 才能得到 int ## 跳脫 常用跳脫字元  如果想印出 \,必須在前面多加一個 \ ,也就等於 \\
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up