Building the Right Environment to Support AI, Machine Learning and Deep Learning

If you have multiple , you can use to them efficiently.

import java.util.StringJoiner;

public class UsingStringJoiner
{
   public static void main(String args[])
   {
      UsingStringJoiner usingStringJoiner = new UsingStringJoiner();
      usingStringJoiner.proceed();
   }
   
   private void proceed()
   {
      StringJoiner stringArr = new StringJoiner(",", "{", "}");   
      //Here comma (,) is the delimiter and {} are the start and end suffix
          
        stringArr.add("Sun Microsystems");  
        stringArr.add("Oracle");  
        stringArr.add("Database company");  
        stringArr.add("Software and Hardware");  
                  
        System.out.println(stringArr);        
   }

}

/*

Expected output:

[[email protected]]# java UsingStringJoiner
{Sun Microsystems,Oracle,Database company,Software and Hardware}

*/ 

 

Visit the DevX Tip Bank

 



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here