Application Security Testing: An Integral Part of DevOps

Iterating a list and printing the values is very simple, as illustrated by the code snippet below.

import .util.*;

public class DoubleColon
{
   public static void main(String args[])
   {
      DoubleColon doubleColon = new DoubleColon();
      doubleColon.proceed();
   }
   
   private void proceed()
   {
      List oddNumbers = new ArrayList();
      //List oddNumbers is created and populated with some odd numbers
      oddNumbers.add(1);
      oddNumbers.add(3);
      oddNumbers.add(5);
      oddNumbers.add(7);
      oddNumbers.add(9);

      System.out.println("Contents of the oddNumbers list");
      //Using the :: here. This explicitly understands and prints the items in the list
      oddNumbers.forEach(System.out::println);   
   }
}

/*

Expected output:

[[email protected]]# java DoubleColon
Contents of the oddNumbers list
1
3
5
7
9

*/

 

Visit the DevX Tip Bank

 



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here