我在过去的2个小时内一直试图制作this,我试过这个并且没有任何错误。
[
{
"storeName": "Ye Olde Candy Shoppe",
"address": "1313 Vampire Lane, Cityville NY 99999",
"zipCode": "99999",
"storeSize": "large",
"visits": [
{
"key": "5/3/12",
"values": [
{
"storeID": "53454447",
"storeName": "Ye Olde Candy Shoppe",
"city": "Cityville",
"building": "1313",
"street": "Vampire Lane",
"zipcode": "99999",
"storeSize": "large",
"storeVisitDate": "5/3/12",
"action": "Return",
"dollarAmount": "65.43"
},
{
"storeID": "53454447",
"storeName": "Ye Olde Candy Shoppe",
"city": "Cityville",
"building": "1313",
"street": "Vampire Lane",
"zipcode": "99999",
"storeSize": "large",
"storeVisitDate": "5/3/12",
"action": "Purchase",
"dollarAmount": "12.43"
},
{
"storeID": "53454447",
"storeName": "Ye Olde Candy Shoppe",
"city": "Cityville",
"building": "1313",
"street": "Vampire Lane",
"zipcode": "99999",
"storeSize": "large",
"storeVisitDate": "5/3/12",
"action": "Purchase",
"dollarAmount": "5.43"
}
]
},
{
"key": "12/31/12",
"values": [
{
"storeID": "53454447",
"storeName": "Ye Olde Candy Shoppe",
"city": "Cityville",
"building": "1313",
"street": "Vampire Lane",
"zipcode": "99999",
"storeSize": "large",
"storeVisitDate": "12/31/12",
"action": "Purchase",
"dollarAmount": "2.53"
}
]
},
{
"key": "1/24/13",
"values": [
{
"storeID": "53454447",
"storeName": "Ye Olde Candy Shoppe",
"city": "Cityville",
"building": "1313",
"street": "Vampire Lane",
"zipcode": "99999",
"storeSize": "large",
"storeVisitDate": "1/24/13",
"action": "Return",
"dollarAmount": "2.53"
},
{
"storeID": "53454447",
"storeName": "Ye Olde Candy Shoppe",
"city": "Cityville",
"building": "1313",
"street": "Vampire Lane",
"zipcode": "99999",
"storeSize": "large",
"storeVisitDate": "1/24/13",
"action": "Return",
"dollarAmount": "64.22"
}
]
}
]
},
{
"storeName": "Mike's Bikes",
"address": "2626 Aardvark Circle, Townsville NY 88888",
"zipCode": "88888",
"storeSize": "small",
"visits": [
{
"key": "8/8/14",
"values": [
{
"storeID": "24335234",
"storeName": "Mike's Bikes",
"city": "Townsville",
"building": "2626",
"street": "Aardvark Circle",
"zipcode": "88888",
"storeSize": "small",
"storeVisitDate": "8/8/14",
"action": "Purchase",
"dollarAmount": "443.55"
},
{
"storeID": "24335234",
"storeName": "Mike's Bikes",
"city": "Townsville",
"building": "2626",
"street": "Aardvark Circle",
"zipcode": "88888",
"storeSize": "small",
"storeVisitDate": "8/8/14",
"action": "Purchase",
"dollarAmount": "34"
},
{
"storeID": "24335234",
"storeName": "Mike's Bikes",
"city": "Townsville",
"building": "2626",
"street": "Aardvark Circle",
"zipcode": "88888",
"storeSize": "small",
"storeVisitDate": "8/8/14",
"action": "Purchase",
"dollarAmount": "12.32"
}
]
},
{
"key": "10/3/15",
"values": [
{
"storeID": "24335234",
"storeName": "Mike's Bikes",
"city": "Townsville",
"building": "2626",
"street": "Aardvark Circle",
"zipcode": "88888",
"storeSize": "small",
"storeVisitDate": "10/3/15",
"action": "Purchase",
"dollarAmount": "233.1"
},
{
"storeID": "24335234",
"storeName": "Mike's Bikes",
"city": "Townsville",
"building": "2626",
"street": "Aardvark Circle",
"zipcode": "88888",
"storeSize": "small",
"storeVisitDate": "10/3/15",
"action": "Return",
"dollarAmount": "44.99"
}
]
}
]
}
]
答案 0 :(得分:1)
将System.out.println();
移出内部for循环。
public class truefalse {
public static void main(String[] args){
int nums[][] = new int[5][5];
for (int i=0; i<5; i++){
for (int j=0;j<5; j++){
if(j!=i){
nums[i][j]=0;
} else if(j==i){
nums[i][j]=1;
}
System.out.print(nums[i][j]);
}
System.out.println();
}
}
}
此代码的输出为
10000
01000
00100
00010
00001
答案 1 :(得分:0)
int nums[][] = new int[5][5];
for (int i=0; i<5; i++) {
for (int j=0;j<5; j++) {
if(j!=i) {
nums[i][j]=0;
} else if(j==i) {
nums[i][j]=1;
}
System.out.print(nums[i][j]);
}
System.out.println();
}