variables - 同时初始化两个不同的随机变量
问题描述
我正在使用'java.util.Random'编写一个脚本,并且我试图为同一个println初始化两个随机变量,但它只有在我注释掉其中一个变量时才有效。这是我的问题所在的代码:
Random a = new Random();
date = a.nextInt(29) + 1;
year = a.nextInt(2019 - 2044)+ 1;
System.out.println("The best day of your life will be on " + month + " " + date + ","+ " " + year + ".....give or take.\n");
System.out.println("Which date of the month do you believe is your luckiest?");
我不知道如何同时初始化“日期”和“年份”。任何帮助表示赞赏。
解决方案
推荐阅读
- python - 使用 tkinter 按钮在另一个窗口中控制 Python 乌龟
- teamcity - 如何让 Team City 检出分支的最新版本 - 无论标签是否存在
- python - 在 Jenkins 的 Python 作业中包含自定义库
- ruby-on-rails - 捕获错误并停止程序的正确方法是什么?
- jupyter-notebook - How to do authentication with Kerberos in Jupyter notebook
- excel - KDB: Preserve Leading Zeros When Saving Data to CSV?
- yii2 - Yii composer dependencies not updating
- cypher - Cypher query: How to compute cosine similarity in Agensgraph, and SAP HANA
- ios - 自定义事件未登录 Firebase Analytics 事件部分
- c# - 为什么我在使用 IronPython 导入库时收到 Microsoft.Scripting.SyntaxErrorException: unexpected token ','