小编jat*_*ngh的帖子

Java代码问题将十进制代码转换为十六进制?

我在下面有Java代码演示,它给了我一些问题.

这是一个例子:

public class MyTest 
{
    public static void main(String as[])
    {
        String ColorHex="#4EB3A2";
        int RedColor = Integer.parseInt(ColorHex.substring(1,3), 16);
        int GreenColor = Integer.parseInt(ColorHex.substring(3,5), 16);
        int BlueColor = Integer.parseInt(ColorHex.substring(5,7), 16);
        int finalColorValue = 65536 * RedColor + 256*GreenColor + BlueColor;
        int ColorDecimal=finalColorValue;
        int red = ColorDecimal % 256;
        ColorDecimal = ( ColorDecimal - red ) / 256;
        int green = ColorDecimal % 256;
        ColorDecimal = ( ColorDecimal - green ) / 256;
        int blue = ColorDecimal % 256;
        ColorDecimal = ( …
Run Code Online (Sandbox Code Playgroud)

java hex decimal

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

标签 统计

decimal ×1

hex ×1

java ×1