小编Imu*_*ugi的帖子

字符串引用

String s1 = "String";
String s2 = "String" + "";
String s3 = "" + s2;
System.out.println (s1 == s2);
System.out.println (s2 == s3);
System.out.println (s1 == s3);

true 
false 
false
Run Code Online (Sandbox Code Playgroud)

为什么我会得到错误的价值观?字符串池中不应该是s3变量?一样的.好像我完全不了解String pool.

java

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

如何在C#中停止工作构造函数?

这是典型的课程.

class Round
{
    private int radius;

    private bool Validate(int radius) 
    {

            if (radius <= 0)
            {
            return false;
            }
            else
        {
            return true;
        }

    }

    public int X { get; set;}
    public int Y { get; set;}

    public int Radius
    {
        get
        {
            return radius;
        }

        set
        {
            try
            {   
                if(!Validate(value))
                {
                    throw new ArgumentException();
                }
            radius = value;
            }
            catch (ArgumentException)
            {

                Console.WriteLine("ooops... something went wrong.");
                return;
            }

        }
    }

    public Round (int X, int Y, int radius) …
Run Code Online (Sandbox Code Playgroud)

c#

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

标签 统计

c# ×1

java ×1