我正在尝试创建一个随机电话号码生成器。下面的代码有效,但输出为负数。我如何使它成为积极的?我应该使用绝对函数吗?以及如何让它更随机?
import java.util.Random;
public class RandPhone
{
public static void main (String[] args)
{
System.out.println ( "Generating a random string of numerals for Human communication system.");
Random generator = new Random(1234567890);
int r = generator.nextInt()*-1;
System.out.println ( r);
}
}