Pārlūkot izejas kodu

my person details

Simran Bhutani 6 gadus atpakaļ
vecāks
revīzija
9c5498d7d9
1 mainītis faili ar 11 papildinājumiem un 1 dzēšanām
  1. 11
    1
      src/main/java/com/zipcodewilmington/PersonHandler.java

+ 11
- 1
src/main/java/com/zipcodewilmington/PersonHandler.java Parādīt failu

@@ -12,6 +12,12 @@ public class PersonHandler {
12 12
 
13 13
     public String whileLoop() {
14 14
         String result = "";
15
+        int counter =0;
16
+        while(counter<personArray.length){
17
+            result= result.concat(personArray[counter].toString());
18
+            counter++;
19
+
20
+        }
15 21
         // assume there is a `counter`
16 22
         // while `counter` is less than length of array
17 23
             // begin loop
@@ -28,7 +34,8 @@ public class PersonHandler {
28 34
 
29 35
     public String forLoop() {
30 36
         String result = "";
31
-        // identify initial value
37
+        for(int counter=0; counter< personArray.length; counter++)
38
+            result=result.concat(personArray[counter].toString());// identify initial value
32 39
         // identify terminal condition
33 40
         // identify increment
34 41
 
@@ -46,6 +53,9 @@ public class PersonHandler {
46 53
 
47 54
     public String forEachLoop() {
48 55
         String result = "";
56
+        for(Person counter : personArray)
57
+            result= result.concat(counter.toString());
58
+
49 59
         // identify array's type
50 60
         // identify array's variable-name
51 61