📄 testflyweight.java
字号:
public class TestFlyweight
{
public static void main(String args[])
{
String names[] = {"Ralph", "Alice", "Sam"};
int ids[] = {1001, 1002, 1003};
int scores[] = {45, 55, 65};
double total = 0;
for (int loopIndex = 0; loopIndex < scores.length; loopIndex++){
total += scores[loopIndex];
}
double averageScore = total / scores.length;
Student student = new Student(averageScore);
for (int loopIndex = 0; loopIndex < scores.length; loopIndex++){
student.setName(names[loopIndex]);
student.setId(ids[loopIndex]);
student.setScore(scores[loopIndex]);
System.out.println("Name: " + student.getName());
System.out.println("Standing: " +
Math.round(student.getStanding()));
System.out.println("");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -