小编gna*_*nja的帖子

String.equals with each和for循环

String[] rgb = new String[3];

rgb[0] = Integer.toHexString(color.getRed());
rgb[1] = Integer.toHexString(color.getGreen());
rgb[2] = Integer.toHexString(color.getBlue());

for(String el : rgb)
{
    if(el.equals("0"))
    {
        el = "00";
    }
}

for(int i = 0; i<3; i++)
{
    if(rgb[i].equals("0"))
    {
        rgb[i] = "00";
    }
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,我根据天气评估每个索引,每个索引都是=零.但它总是在foreach循环中运行false,并且在for循环中适当时为true.谁能解释幕后发生的事情才能实现这一目标?

我没有按顺序运行它们,它们都用于演示目的.

java foreach for-loop

2
推荐指数
1
解决办法
957
查看次数

Math.E和e之间有什么区别?

所以,如果我跑

System.out.println(1e+0);
Run Code Online (Sandbox Code Playgroud)

它输出1

但是,如果我跑

System.out.println(Math.E);
Run Code Online (Sandbox Code Playgroud)

它输出2.718 .........

对于我的生活,我无法弄清楚小e如何与数字交互我得到Math.E是一个与对数有关的常数但我认为小e只是用数字表示而代码是向我展示不同的东西.谁能解释这个e如何与java中的数字交互?

java math double scientific-notation

1
推荐指数
1
解决办法
1401
查看次数

标签 统计

java ×2

double ×1

for-loop ×1

foreach ×1

math ×1

scientific-notation ×1