Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update

  • Loading branch information...
commit acf2a1a4efffff71e05b1f0405be17e0772bf3ed 1 parent 6fbf88c
@astrotycoon authored
View
BIN  enum_array/Clolor.class
Binary file not shown
View
BIN  enum_array/WeekDay.class
Binary file not shown
View
BIN  enum_array/WeekDays.class
Binary file not shown
View
BIN  enum_array/enum_array.class
Binary file not shown
View
26 enum_array/enum_array.java
@@ -0,0 +1,26 @@
+public class enum_array {
+ public static void main(String args[]) {
+ WeekDays enum_arr[] = WeekDays.values();
+ for (WeekDays day:enum_arr) {
+ System.out.println(day);
+ }
+
+ for (Clolor a:Clolor.values()) {
+ for (Clolor b:Clolor.values()) {
+ for (Clolor c:Clolor.values()) {
+ if (a != b && a != c && b != c) {
+ System.out.println(a +","+ b +","+ c +"|");
+ }
+ }
+ }
+ }
+ }
+}
+
+enum WeekDays {
+ sun, mon, tue, wed, thu, fri, sat
+}
+
+enum Clolor {
+ 红, 蓝, 绿, 黄, 黑
+}
View
BIN  for_array/for_array.class
Binary file not shown
View
24 for_array/for_array.java
@@ -0,0 +1,24 @@
+public class for_array {
+ public static void main(String[] args) {
+ int a[] = {1, 2, 3, 4};
+ char b[] = {'a', 'b', 'c', 'd'};
+
+ //传统方式
+ for (int n = 0; n < a.length; n++) {
+ System.out.println(a[n]);
+ }
+
+ for (int n = 0; n < b.length; n++) {
+ System.out.println(b[n]);
+ }
+
+ //改进方式
+ for (int i: a) {
+ System.out.println(i);
+ }
+
+ for (char i:b) {
+ System.out.println(i);
+ }
+ }
+}
View
BIN  for_enum_switch/Fruit.class
Binary file not shown
View
BIN  for_enum_switch/for_enum_switch$1.class
Binary file not shown
View
BIN  for_enum_switch/for_enum_switch.class
Binary file not shown
View
35 for_enum_switch/for_enum_switch.java
@@ -0,0 +1,35 @@
+enum Fruit {
+ apple, pear, banana, watermelon
+}
+public class for_enum_switch {
+ public static void main(String args[]) {
+ double price = 0;
+ boolean show = false;
+
+ for (Fruit fruit:Fruit.values()) {
+ switch(fruit) {
+ case apple:
+ price = 1.5;
+ show = true;
+ break;
+ case pear:
+ price = 6.8;
+ show = true;
+ break;
+ case banana:
+ price = 2.8;
+ show = true;
+ break;
+ case watermelon:
+ price = 2.5;
+ show = true;
+ break;
+ default:
+ show = false;
+ }
+ if (show) {
+ System.out.println(fruit +"500克的价格:"+ price +"");
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.