0

如何为变量堆栈进行质量分配?

我声明变量列表

String not_id, not_section, not_steet, not_sqTotal, not_sqLiving, not_sqKitchen, not_flat, not_floor, not_floors, not_text, user_phone1, user_phone2, user_contact, not_region, not_district, not_settle, not_price, not_photo, not_date, not_date_till, not_up, not_premium, not_status;

我希望它们都等于""- 空字符串(或者"a",无关紧要只是一个例子)

4

5 回答 5

6
not_id = not_section = ... = not_status = "";
于 2013-04-15T14:28:49.517 回答
1
String not_id, not_section, not_steet, not_sqTotal, not_sqLiving, not_sqKitchen, not_flat, not_floor, not_floors, not_text, user_phone1, user_phone2, user_contact, not_region, not_district, not_settle, not_price, not_photo, not_date, not_date_till, not_up, not_premium, not_status;

not_id = not_section = not_steet = not_sqTotal = not_sqLiving = not_sqKitchen = not_flat = not_floor = not_floors = not_text = user_phone1 = user_phone2 = user_contact = not_region = not_district = not_settle = not_price = not_photo = not_date = not_date_till = not_up = not_premium = not_status = "";
于 2013-04-15T14:29:50.817 回答
1
String not_id=not_section=not_steet=not_sqTotal=not_sqLiving=not_sqKitchen=not_flat=not_floor=not_floors=not_text=user_phone1=user_phone2=user_contact=not_region=not_district=not_settle=not_price=not_photo=not_date=not_date_till=not_up=not_premium=not_status="a";
于 2013-04-15T14:30:56.663 回答
0

带有for循环的数组或其他集合。你能想出的任何解决方案都会减少到那个程度。如果值不是同质的,不属于数组,则必须为每个要实际分配给某物的变量分配一个分配。没有办法解决这个问题。

通常,如果您希望将所有对象初始化为复杂的东西,您可以创建一个带有默认构造函数的包装类,该构造函数封装它,但在您的情况下这将是更多的工作。例如

Foo a = new Foo(1, 2, 3);
Foo b = new Foo(1, 2, 3);

可以换成

Foo a = new FooW();

Where使用调用的默认构造函数进行FooW扩展。Foosuper(1, 2, 3)

于 2013-04-15T14:28:27.690 回答
-1

循环它

for (String s: list) {
            s=""; 
            //or 
            s="a";
        }
于 2013-04-15T14:29:41.410 回答