Searching...
Monday, September 10, 2018

Java 10 Arrays with local variable Var and Different ways to iterate

September 10, 2018

Java10ArrayWithLocalVar.java
 package com.java9r;

public class Java10ArrayWithLocalVar {

public static void main(String[] args) {
String[] products = new String[8];
products[0] = "product 1";
products[1] = "product 2";
products[2] = "product 3";
products[3] = "product 4";
products[4] = "product 5";
products[5] = "product 6";
products[6] = "product 7";
products[7] = "product 8";

System.out.println("Products List using enhanced for loop");
for (var product : products) {
System.out.println(product);
}

System.out.println("Products List using for loop ");
for (var i = 0; i < products.length; i++) {
System.out.println(products[i]);
}

System.out.println("Iterate list using while loop ");
var i = 0;

while (i < products.length) {

System.out.println(products[i]);
i++;
}

}
}


Output
Products List using enhanced for loop
product 1
product 2
product 3
product 4
product 5
product 6
product 7
product 8
Products List using for loop
product 1
product 2
product 3
product 4
product 5
product 6
product 7
product 8
Iterate list using while loop
product 1
product 2
product 3
product 4
product 5
product 6
product 7
product 8


1 comments:

  1. That is the part that you simply were looking at at} up on the on the machine here. So it's an injection molded part that performs like injection molded elements do that is masquerading as an additive manufactured part. You can eventually lower your molding time by using multiple of} cavity molds. This serves to extend your manufacturing pace and scale back your manufacturing part value. Smaller runners, the opposite hand|however|then again}, minimize cooling time, scrap, and in the end part value. The draw back to small runners is the coolest shower curtains higher stress required to pressure the recent resin to circulate through them.

    ReplyDelete