Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   






Join() FUNCTION


Join() Function


The Join() Function is used to join all the elements of an array into one string.


Example :



package main
import "fmt"
import "strings"
    
func main() {
    
    x := []string{"Hello", "Beautiful", "World"}
    y := strings.Join(x, "@")
    fmt.Println(y)  	
}	


Output :



 Hello@Beautiful@World

In the above code, we have declared an array with values 'Hello', 'Beautiful' and 'World'.And assigned it to a variable 'x'.


x := []string{"Hello", "Beautiful", "World"}

java_Collections

Then we have used the 'Join()' function to take all the three values from the array and join them, separated using '@'.


y := strings.Join(x, "@")

java_Collections