Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何做集体作业_Java - Fatal编程技术网

Java 如何做集体作业

Java 如何做集体作业,java,Java,如何对变量堆栈进行大规模关联 我声明变量列表 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

如何对变量堆栈进行大规模关联

我声明变量列表

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”
,不只是一个例子)

一个数组或其他集合,带有
for
循环。你能想出的任何解决办法都会减少到这个程度。如果值不是齐次的,因此不属于数组,则必须为每个要实际分配给某个对象的变量分配一个赋值。这是没有办法的

一般来说,如果希望所有对象都初始化为复杂的对象,可以创建一个包含默认构造函数的包装类来封装它,但在您的情况下,这将需要更多的工作。e、 g

Foo a = new Foo(1, 2, 3);
Foo b = new Foo(1, 2, 3);
可以替换为

Foo a = new FooW();
其中
FooW
使用调用
super(1,2,3)
循环它的默认构造函数扩展
Foo

for (String s: list) {
            s=""; 
            //or 
            s="a";
        }

这不是Java的语言特性。“我声明变量列表”…无论如何祝贺第一次否决:)。我同意。。我的假设是错误的。这假设除了
not\u id
之外的所有字符串都已声明。
for (String s: list) {
            s=""; 
            //or 
            s="a";
        }
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 = "";
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";