# 将内容从一个数组存储到另一个数组Store contents from an array into another array

``````double [] anArray = new double[366];//Keep track of all the days in the year
String [] weekday = new String[366];//I hope to store the day names in this array
String days[]={"monday","tuesday","wednesday","thursday",
"friday","saturday","sunday"};

//---each letter is 0 to start each new month at monday---
int a=0;int b=0;int c=0;int d=0;int e=0;int f=0;int g=0;int h=0;int i=0;
int j=0;int k=0;int l=0;//Days counter
//--These start at 1 to start each new month on the 1st
int jandays=1;int febdays=1;int mardays=1;int aprdays=1;int maydays=1;int jundays=1;
int juldays=1;int augdays=1;int septdays=1;int octdays=1;int novdays=1;int decdays=1;

//Temperatures for February
for(int feb=31;feb <= 58;feb++){
anArray[feb]=(int)(26 + Math.random() * (40-26+1));

//System.out.println(days[b++ %7] + " january "+ (febdays++) +" at "+ anArray[feb]+" degrees"); // This is just testing to see if everything checks out.

febtotal += anArray[feb];
}
febavg= febtotal/31;
System.out.printf("The Average temperature in February: "+"%.2f",febavg);
System.out.println("");
``````

## 1 个回复1

### ===============>>#1 票数：0

``````public class WeekDay {
private int number;
private String name;

public WeekDay(int number, String name) {
}

/** GETTERS AND SETTERS **/
}
``````

``````List<WeekDay> weekDays = new ArrayList<WeekDay>();
``````

`WeekDay`对象平均后，您可以循环浏览每个`getName()` ，然后调用`getName()` （您需要添加此名称以返回日期名称。 这提供了更简洁，更易于管理和更易于使用的代码，并且将帮助您更有效地概念化目标。 老实说，在复杂情况下，OOP非常棒。

`````` [0] = 0
[1] = 0
.
.
.
[34] = 3
[35] = 9
.
.
.
[62] = 7
[63] = 0
``````

`````` public String[] mapDays(int[] dayNumbers, int startNumber, int endNumber) {
}
``````

`````` // First, you make a new array.
String[] dayNames = new String[dayNumbers.length];

for(int x = startNumber; x <= endNumber; x++) {
// You now need to map the value of x, to the week day name.

}
``````